﻿:root {
    --bg: #0b1020; --bg2: #111a2e; --card: #141e33; --border: #26334d;
    --text: #e6edf7; --muted: #8b9bb4; --accent: #6366f1; --accent2: #22d3ee;
    --green: #10b981; --red: #ef4444; --amber: #f59e0b; --purple: #a78bfa;
    --input: #0d1526; --thead: #0f1930; --hover: #1a2540;
}
body.light {
    --bg: #eceff3; --bg2: #e5e9ef; --card: #f7f8fb; --border: #d5dbe4;
    --text: #1e2735; --muted: #5d6b82; --input: #ffffff; --thead: #eff2f6; --hover: #e9edf3;
}
* { box-sizing: border-box; font-family: 'Inter', sans-serif; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); overflow-x: hidden; transition: background .25s, color .25s; }
.mono { font-family: 'JetBrains Mono', monospace; }
.ic { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: inline-block; vertical-align: -2px; flex-shrink: 0; }
.ic-lg { width: 30px; height: 30px; stroke-width: 1.5; }
.dropzone .ic-lg { width: 40px; height: 40px; }
.nav-ic { width: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-ic .ic { width: 16px; height: 16px; }
.icon-btn .ic { width: 14px; height: 14px; }
.btn .ic { width: 13px; height: 13px; }

/* ===== Home / main menu ===== */
#home-screen { min-height: 100vh; flex-direction: column; align-items: center; justify-content: center; gap: 34px; padding: 40px 24px; }
.home-brand { display: flex; align-items: center; gap: 12px; }
.home-cards { display: flex; gap: 26px; flex-wrap: wrap; justify-content: center; }
.home-card { width: 380px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 30px; cursor: pointer; transition: .2s; text-align: left; }
.home-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 18px 44px rgba(15, 23, 42, .14); }
.hc-top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.hc-ic { width: 48px; height: 48px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--accent); flex-shrink: 0; }
.hc-ic .ic { width: 22px; height: 22px; }
.hc-title { font-size: 17px; font-weight: 800; letter-spacing: -.3px; }
.hc-sub { font-size: 10.5px; color: var(--muted); letter-spacing: 1.2px; text-transform: uppercase; font-weight: 700; margin-top: 3px; }
.hc-desc { font-size: 12.5px; color: var(--muted); line-height: 1.65; min-height: 84px; }
.hc-meta { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.home-foot { font-size: 11.5px; color: var(--muted); }

/* ===== Shared shell ===== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; transition: .25s; }
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.brand-logo { width: 38px; height: 38px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 800; color: #fff; flex-shrink: 0; }
.brand-name { font-size: 15px; font-weight: 800; letter-spacing: -.3px; line-height: 1.1; }
.brand-sub { font-size: 9.5px; color: var(--muted); letter-spacing: 1.4px; text-transform: uppercase; font-weight: 600; }
.nav-list { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 9.5px; color: var(--muted); letter-spacing: 1.4px; text-transform: uppercase; font-weight: 700; padding: 12px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted); transition: .15s; margin-bottom: 2px; border: 1px solid transparent; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 4px 14px rgba(99, 102, 241, .35); }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.nav-item.active .nav-badge { background: rgba(255, 255, 255, .25); }
.side-foot { padding: 12px 14px; border-top: 1px solid var(--border); }
.side-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 8px; border-radius: 8px; background: var(--card); border: 1px solid var(--border); color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer; transition: .15s; }
.side-btn:hover { border-color: var(--accent); color: var(--accent); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--bg2); border-bottom: 1px solid var(--border); padding: 12px 22px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; position: sticky; top: 0; z-index: 50; }
.tabbar-label { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.4px; font-weight: 700; margin-right: 2px; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg2); font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s; color: var(--text); max-width: 200px; }
.tab:hover { border-color: var(--accent); }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-x { opacity: .55; font-size: 11px; }
.tab-x:hover { opacity: 1; color: var(--red); }
.tab-live { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; flex-shrink: 0; box-shadow: 0 0 0 3px rgba(16, 185, 129, .15); }
.tab-add { width: 32px; height: 32px; border-radius: 8px; border: 1px dashed var(--border); background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.tab-add:hover { border-color: var(--accent); color: var(--accent); }
.ds-name { background: transparent; border: 1px solid transparent; color: var(--text); font-size: 16px; font-weight: 800; letter-spacing: -.3px; padding: 4px 8px; border-radius: 6px; min-width: 110px; max-width: 240px; }
.ds-name:hover, .ds-name:focus { border-color: var(--border); background: var(--input); outline: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--border); padding: 5px 11px; border-radius: 20px; font-size: 11px; font-weight: 600; color: var(--muted); }
.pill b { color: var(--text); font-family: 'JetBrains Mono', monospace; }
.pill-live { cursor: pointer; border-color: var(--green); }
.pill-live:hover { background: var(--hover); }
.tb-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; background: var(--card); border: 1px solid var(--border); color: var(--text); cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: .15s; }
.icon-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.content { padding: 22px; max-width: 1650px; width: 100%; margin: 0 auto; flex: 1; }
.content.grid-max { padding: 12px 14px 14px; max-width: none; display: flex; flex-direction: column; }
#view-grid.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#view-grid .table-wrap { flex: 1; min-height: 220px; max-height: none; }
#view-grid .empty-state { margin-top: 10px; }
#filterChips { flex-shrink: 0; }
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.v-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.v-title { font-size: 21px; font-weight: 800; letter-spacing: -.4px; display: flex; align-items: center; gap: 10px; }
.v-title .ic { width: 19px; height: 19px; color: var(--accent); }
.v-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.card-h { font-size: 13.5px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; align-items: end; }
@media(max-width: 1000px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .sidebar { width: 64px; }
    .sidebar .brand-name, .sidebar .brand-sub, .sidebar .nav-label, .nav-item span.lbl, .side-btn span { display: none; }
    .nav-item { justify-content: center; }
    .side-btn { font-size: 15px; }
    .rightbar { display: none !important; }
}
.input, .select, textarea { background: var(--input); border: 1px solid var(--border); color: var(--text); padding: 7px 11px; border-radius: 7px; font-size: 12.5px; width: 100%; transition: .15s; }
.input:focus, .select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }
label { font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .8px; display: block; margin-bottom: 6px; }
.btn { background: var(--accent); color: #fff; border: none; padding: 7px 14px; border-radius: 7px; font-size: 12px; font-weight: 700; cursor: pointer; transition: .15s; display: inline-flex; align-items: center; gap: 7px; }
.btn:hover { filter: brightness(1.12); }
.btn-green { background: var(--green); } .btn-red { background: var(--red); } .btn-amber { background: var(--amber); }
.btn-purple { background: var(--purple); } .btn-cyan { background: #0891b2; }
.btn-light { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-light:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.btn-sm { padding: 4px 10px; font-size: 11px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; background: var(--card); }
th { text-align: left; padding: 8px 10px; background: var(--thead); color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; border: 1px solid var(--border); position: sticky; top: 0; z-index: 10; vertical-align: top; }
td { padding: 4px 8px; border: 1px solid var(--border); color: var(--text); }
tr.hl-row td { background: rgba(245, 158, 11, .09); }
body.light tr.hl-row td { background: rgba(245, 158, 11, .18); }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--card); max-height: calc(100vh - 290px); }
.cell-in { background: transparent; border: 1px solid transparent; color: var(--text); padding: 4px 6px; font-size: 12.5px; width: 100%; border-radius: 4px; font-family: inherit; }
.cell-in:hover { border-color: var(--border); }
.cell-in:focus { outline: none; border-color: var(--accent); background: var(--input); }
.col-head { min-width: 130px; }
#gridTableWrap table { table-layout: fixed; }
#gridTableWrap th.col-head, #gridTableWrap td.cell { width: 150px; min-width: 150px; max-width: 150px; overflow: hidden; }
#gridTableWrap th.rowchk, #gridTableWrap td.rowchk { width: 34px; min-width: 34px; text-align: center; vertical-align: middle; }
#gridTableWrap th.sp, #gridTableWrap td.sp { border: 0; padding: 0; }
#gridTableWrap tr.drow { height: 34px; }
#gridTableWrap .cell-in { height: 26px; }
#gridTableWrap td { white-space: nowrap; }
#filterChips { display: none; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 8px; }
.fchip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg2); border: 1px solid var(--accent); color: var(--text); font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 14px; }
.fchip-x { cursor: pointer; color: var(--muted); }
.fchip-x:hover { color: var(--red); }
.qchk { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text); }
.type-badge { font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 4px; letter-spacing: .5px; text-transform: uppercase; }
.t-number { background: rgba(99, 102, 241, .18); color: #a5b4fc; }
.t-text { background: rgba(148, 163, 184, .18); color: #94a3b8; }
.t-date { background: rgba(34, 211, 238, .15); color: #67e8f9; }
.t-email { background: rgba(236, 72, 153, .15); color: #f9a8d4; }
.t-url { background: rgba(16, 185, 129, .15); color: #6ee7b7; }
.t-bool { background: rgba(245, 158, 11, .18); color: #fcd34d; }
.t-formula { background: rgba(167, 139, 250, .18); color: #c4b5fd; }
body.light .t-number { background: rgba(79, 70, 229, .1); color: #4338ca; }
body.light .t-text { background: rgba(100, 116, 139, .12); color: #64748b; }
body.light .t-date { background: rgba(8, 145, 178, .1); color: #0e7490; }
body.light .t-email { background: rgba(219, 39, 119, .1); color: #be185d; }
body.light .t-url { background: rgba(5, 150, 105, .1); color: #047857; }
body.light .t-bool { background: rgba(180, 83, 9, .12); color: #b45309; }
body.light .t-formula { background: rgba(124, 58, 237, .1); color: #6d28d9; }
.empty-state { text-align: center; padding: 44px 20px; border: 2px dashed var(--border); border-radius: 14px; background: var(--bg2); color: var(--muted); }
.dropzone { border: 2px dashed var(--border); border-radius: 14px; padding: 40px 24px; text-align: center; cursor: pointer; transition: .2s; background: var(--bg2); }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(99, 102, 241, .06); }
.sug-card { display: flex; gap: 14px; align-items: flex-start; background: var(--bg2); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; }
.sug-crit { border-left-color: var(--red); }
.sug-warn { border-left-color: var(--amber); }
.sug-title { font-size: 13px; font-weight: 700; }
.sug-desc { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.sug-btns { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.rule-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rule-off { opacity: .45; }
.rule-text { font-size: 12.5px; font-family: 'JetBrains Mono', monospace; }
.rule-text b { color: var(--accent2); }
.cond-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; flex-wrap: wrap; }
.cond-row .select { width: auto; min-width: 130px; flex: 1 1 130px; }
.cond-row .input { width: auto; min-width: 120px; flex: 1 1 120px; }
.cond-row .icon-btn { flex-shrink: 0; }
.conn-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.conn-card { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-top: 8px; flex-wrap: wrap; }
.conn-card .ic { width: 16px; height: 16px; color: var(--accent); }
.conn-err { border-color: var(--red); }
.conn-url { font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.hint { font-size: 11px; color: var(--muted); line-height: 1.5; }
.sql-tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.sql-table { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; transition: .15s; }
.sql-table:hover { border-color: var(--accent); }
.switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--border); border-radius: 20px; cursor: pointer; transition: .2s; }
.slider:before { content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(16px); }
.sec-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.sec-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.sec-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 12px; background: var(--bg2); margin-top: 6px; border: 1px solid var(--border); }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.stat-l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.stat-v { font-size: 22px; font-weight: 800; margin-top: 5px; font-family: 'JetBrains Mono', monospace; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.tile { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.tile .stat-v { font-size: 15px; margin-top: 3px; }
.corr-table td, .corr-table th { text-align: center; padding: 5px 8px; font-size: 11px; font-family: 'JetBrains Mono', monospace; }
.insight-item { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; line-height: 1.55; color: var(--text); }
.insight-item:last-child { border-bottom: 0; }
.an-result { font-size: 26px; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
select[multiple] { height: auto; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; font-size: 11.5px; }
.bar-track { flex: 1; height: 14px; background: var(--bg2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.prof-col { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--card); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--green); padding: 12px 18px; border-radius: 10px; font-size: 13px; transform: translateY(90px); opacity: 0; transition: .3s; z-index: 1000; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); max-width: 400px; }
body.light .toast { box-shadow: 0 10px 30px rgba(15, 23, 42, .14); }
.toast.show { transform: translateY(0); opacity: 1; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.bulk-bar { position: sticky; bottom: 14px; z-index: 40; background: var(--card); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 16px; display: none; align-items: center; gap: 10px; flex-wrap: wrap; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); margin-top: 12px; }
.bulk-bar.show { display: flex; }
.chk { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }
#sqlErr { display: none; background: rgba(239, 68, 68, .1); border: 1px solid rgba(239, 68, 68, .4); color: #fca5a5; border-radius: 8px; padding: 10px 14px; font-size: 12.5px; margin-top: 10px; font-family: 'JetBrains Mono', monospace; }
body.light #sqlErr { color: #b91c1c; }
kbd { background: var(--bg2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 10.5px; font-family: 'JetBrains Mono', monospace; }
.help-row { display: flex; gap: 10px; font-size: 12px; color: var(--muted); line-height: 1.7; margin-bottom: 4px; }
.help-row code { font-family: 'JetBrains Mono', monospace; color: var(--accent2); font-size: 11.5px; white-space: nowrap; }

/* SQL editor */
.editor-wrap { display: flex; background: #0d1117; border: 1px solid #30363d; border-radius: 8px; overflow: hidden; position: relative; }
.editor-gutter { padding: 12px 10px 12px 14px; color: #484f58; font-family: 'JetBrains Mono', monospace; font-size: 13px; line-height: 1.55; user-select: none; background: #161b22; border-right: 1px solid #21262d; white-space: pre; min-width: 44px; text-align: right; overflow: hidden; }
.editor-stack { position: relative; flex: 1; min-width: 0; }
.editor-hl, .editor-input { margin: 0; padding: 12px 14px; font-size: 13px; line-height: 1.55; font-family: 'JetBrains Mono', monospace; white-space: pre-wrap; word-wrap: break-word; overflow: auto; tab-size: 2; box-sizing: border-box; }
.editor-hl { position: absolute; inset: 0; color: #e6edf3; pointer-events: none; background: transparent; overflow: hidden; }
.editor-input { position: relative; width: 100%; min-height: 160px; height: 100%; background: transparent; color: transparent; caret-color: #22d3ee; border: none; resize: vertical; outline: none; }
.editor-input::selection { background: rgba(34, 211, 238, .30); }
.editor-input:focus { border: none; box-shadow: none; }
.editor-hl .hljs-keyword { color: #ff7b72; }
.editor-hl .hljs-string { color: #a5d6ff; }
.editor-hl .hljs-number { color: #79c0ff; }
.editor-hl .hljs-literal { color: #79c0ff; }
.editor-hl .hljs-comment { color: #8b949e; font-style: italic; }
.editor-hl .hljs-built_in, .editor-hl .hljs-function, .editor-hl .hljs-title { color: #d2a8ff; }
.editor-hl .hljs-operator { color: #ff7b72; }
.editor-hl .hljs-punctuation { color: #c9d1d9; }

/* ===== Dashboard studio ===== */
.dash-main { flex: 1; display: flex; min-width: 0; }
.view-dash { display: none; }
.view-dash.active { display: block; }
#dashContent { display: flex; flex-direction: column; }
#dview-canvas.active { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 10px; }
#dview-insights.active { display: block; }
.rightbar { width: 296px; flex-shrink: 0; border-left: 1px solid var(--border); background: var(--bg2); padding: 14px; overflow-y: auto; display: none; flex-direction: column; gap: 6px; }
.rightbar.show { display: flex; }
.rb-h { font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin: 10px 0 6px; }
.pal { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px dashed var(--border); border-radius: 9px; cursor: grab; font-size: 12px; font-weight: 600; background: var(--card); transition: .15s; user-select: none; }
.pal:hover { border-color: var(--accent); color: var(--accent); }
.pal .ic { width: 15px; height: 15px; color: var(--muted); }
.pal:hover .ic { color: var(--accent); }
#dashScroll { overflow: auto; border: 1px solid var(--border); border-radius: 12px; flex: 1; min-height: 400px; position: relative; background: var(--bg2); }
#dashCanvas { position: relative; min-height: 620px; background: var(--bg2); transition: background .25s; }
#dashCanvas.grid { background-image: linear-gradient(rgba(128, 140, 165, .13) 1px, transparent 1px), linear-gradient(90deg, rgba(128, 140, 165, .13) 1px, transparent 1px); background-size: 100% 36px, calc(100% / 12) 100%; }
.widget { position: absolute; border: 1px solid var(--border); border-radius: 10px; background: var(--card); overflow: hidden; display: flex; flex-direction: column; }
.widget.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(99, 102, 241, .28); z-index: 5; }
.w-title { font-size: 12px; font-weight: 700; padding: 7px 11px; border-bottom: 1px solid var(--border); color: var(--muted); flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-body { flex: 1; position: relative; min-height: 0; overflow: hidden; }
.w-chart { position: absolute; inset: 6px 8px 8px; }
.kpi-wrap { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 8px; }
.kpi-v { font-family: 'JetBrains Mono', monospace; font-weight: 800; line-height: 1; }
.kpi-l { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; text-align: center; }
.w-text { height: 100%; overflow: auto; white-space: pre-wrap; padding: 10px 12px; }
.w-table { height: 100%; overflow: auto; }
.w-table table { font-size: 11px; }
.w-table td, .w-table th { padding: 3px 7px; }
.w-line { position: absolute; left: 4%; right: 4%; top: 50%; }
.w-spacer-edit { position: absolute; inset: 4px; border: 1px dashed var(--border); border-radius: 8px; }
.w-del { position: absolute; top: -11px; right: -11px; width: 24px; height: 24px; border-radius: 50%; background: var(--red); color: #fff; border: 2px solid var(--card); display: none; align-items: center; justify-content: center; cursor: pointer; z-index: 10; font-size: 11px; font-weight: 700; }
.w-resize { position: absolute; right: 3px; bottom: 3px; width: 13px; height: 13px; cursor: nwse-resize; border-right: 3px solid var(--accent); border-bottom: 3px solid var(--accent); border-radius: 0 0 4px 0; display: none; }
.widget.sel .w-resize { display: block; }
.w-nodata { height: 100%; display: flex; align-items: center; justify-content: center; font-size: 11.5px; color: var(--muted); text-align: center; padding: 10px; }
.prop-grid { display: grid; gap: 9px; }

/* PDF document styles */
.pdf-doc { font-family: Inter, sans-serif; color: #1e2735; background: #ffffff; padding: 14px 18px; width: 794px; max-width: 100%; }
.pdf-doc h1 { font-size: 23px; margin-bottom: 4px; letter-spacing: -.4px; }
.pdf-doc h2 { font-size: 15px; margin: 20px 0 8px; padding-bottom: 6px; border-bottom: 1px solid #d5dbe4; }
.pd-meta { font-size: 11px; color: #5d6b82; margin-bottom: 12px; }
.pd-text { font-size: 13px; line-height: 1.75; white-space: pre-wrap; }
.pi { display: flex; gap: 9px; padding: 6px 0; border-bottom: 1px solid #eef1f6; font-size: 12.5px; line-height: 1.55; color: #1e2735; }
.pi .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }

/* ===== Dashboard studio — layout & insights fixes ===== */
#tool-dashboard .content { display: flex; flex-direction: column; min-height: 0; max-width: none; padding: 12px 14px 14px; }
#tool-dashboard .dash-main { flex: 1; display: flex; min-height: 420px; min-width: 0; }
#dashScroll { overflow: auto; border: 1px solid var(--border); border-radius: 12px; flex: 1; min-height: 420px; position: relative; background: var(--bg2); }
#dashCanvas { position: relative; min-height: 620px; }
#insOut h2 { font-size: 14px; font-weight: 700; margin: 14px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border); color: var(--text); }
#insOut .pi { display: flex; gap: 9px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; line-height: 1.55; color: var(--text); }
#insOut .pi .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
#insOut .pd-meta { font-size: 11px; color: var(--muted); margin-bottom: 10px; }

/* ===== Sidebar collapse (both studios) ===== */
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .brand { justify-content: center; padding: 18px 8px 14px; }
.sidebar.collapsed .brand-logo { width: 32px; height: 32px; font-size: 13px; }
.sidebar.collapsed .brand-name, .sidebar.collapsed .brand-sub, .sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-item span.lbl, .sidebar.collapsed .nav-badge, .sidebar.collapsed .side-btn span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; }
.sidebar.collapsed .side-btn { font-size: 15px; }

/* ===== Widget delete button: hover-only, inside the widget ===== */
.w-del {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--red);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    font-size: 11px;
    font-weight: 700;
    opacity: 0;
    transition: opacity .15s;
}
.widget:hover .w-del, .widget.sel .w-del { opacity: .9; }
.w-del:hover { opacity: 1; transform: scale(1.08); }

