/* ---------- Dashboard builder ---------- */
.dash-builder { padding: 12px 14px; gap: 10px; }
.db-toolbar { border-radius: var(--radius-lg); padding: 8px 10px; flex: none; }
.db-name { width: 260px; height: 34px; font-weight: 700; font-size: 15px; background: transparent; border-color: transparent; }
.db-name:hover, .db-name:focus { background: var(--input); border-color: var(--line-2); }
.db-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 172px 1fr 300px; gap: 10px; transition: grid-template-columns var(--dur) var(--ease); }
.dash-builder.mode-view .db-body { grid-template-columns: 172px 1fr 0; }
.dash-builder.mode-view .db-panel { display: none; }
.dash-builder.pages-collapsed .db-body { grid-template-columns: 44px 1fr 300px; }
.dash-builder.pages-collapsed.mode-view .db-body { grid-template-columns: 44px 1fr 0; }
.dash-builder.pages-collapsed .db-page-list, .dash-builder.pages-collapsed .db-pages-head .section-title, .dash-builder.pages-collapsed #pg-add { display: none; }
.db-pages { border-radius: var(--radius-lg); padding: 10px 8px; overflow: auto; min-height: 0; }
.db-pages-head { padding: 0 4px 8px; }
.db-page-list { display: flex; flex-direction: column; gap: 3px; }
.db-page { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); border: 1px solid transparent; }
.db-page:hover { background: var(--hover); color: var(--text); }
.db-page.active { background: var(--active); color: var(--text); border-color: rgba(var(--accent-rgb), .35); }
.db-page-num { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 10px; background: var(--glass-2); flex: none; }
.db-page.active .db-page-num { background: var(--accent); color: var(--accent-ink); }
.db-page .icon-btn { opacity: 0; } .db-page:hover .icon-btn { opacity: 1; }
.db-center { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.db-filterbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: none; }
.db-filterbar.empty { display: none; }
.db-filterbar .chip .btn { margin-left: 4px; height: 20px; }
.db-canvas-scroll { flex: 1; min-height: 0; overflow: auto; border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--surface); }
.db-canvas { position: relative; min-height: 100%; }
.db-canvas.show-grid { background-image: linear-gradient(to right, var(--grid-dot) 1px, transparent 1px), linear-gradient(to bottom, var(--grid-dot) 1px, transparent 1px); background-size: var(--col-w, 80px) var(--row-h, 64px); background-position: 12px 12px; }
.db-canvas.drop-target { box-shadow: inset 0 0 0 2px rgba(var(--accent-rgb), .6); }
.canvas-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; color: var(--text-2); padding: 20px; pointer-events: none; }
.canvas-empty * { pointer-events: auto; }
.canvas-empty .icon { color: var(--accent-text); }
.canvas-empty p { max-width: 420px; font-size: 13px; }
.vcard { position: absolute; display: flex; flex-direction: column; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(var(--blur)) saturate(var(--sat)); -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--sat)); box-shadow: var(--shadow); overflow: hidden; transition: box-shadow var(--dur), border-color var(--dur); animation: fadeIn .3s ease; }
.vcard.bg-solid { background: var(--glass-solid); backdrop-filter: none; }
.vcard.bg-none { background: transparent; border-color: transparent; box-shadow: none; backdrop-filter: none; }
.vcard.editable:hover { border-color: rgba(var(--accent-rgb), .35); }
.vcard.selected { border-color: rgba(var(--accent-rgb), .8); box-shadow: var(--shadow), 0 0 0 1px rgba(var(--accent-rgb), .5), 0 10px 30px -10px rgba(var(--accent-rgb), .35); z-index: 3; }
.vcard.dragging { opacity: .85; z-index: 20; box-shadow: var(--shadow-lg); transition: none; }
.vcard-head { display: flex; align-items: center; gap: 6px; min-height: 34px; padding: 8px 8px 0 14px; flex: none; }
.vcard.editable .vcard-head { cursor: move; }
.vcard-title { flex: 1; font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcard.no-title .vcard-title { visibility: hidden; }
.vcard.no-title .vcard-head { position: absolute; top: 0; left: 0; right: 0; z-index: 4; padding-top: 4px; }
.vcard.no-title .vcard-body { padding-top: 10px; }
.vcard-tools { display: flex; align-items: center; gap: 1px; opacity: 0; transition: opacity var(--dur); }
.vcard:hover .vcard-tools, .vcard.selected .vcard-tools { opacity: 1; }
.vcard-tools .icon-btn { width: 24px; height: 24px; }
.vcard-badge { color: var(--accent-text); display: inline-flex; padding: 0 4px; }
.vcard-body { flex: 1; min-height: 0; position: relative; padding: 4px 12px 10px; }
.vcard-foot { flex: none; font-size: 10.5px; color: var(--text-3); padding: 0 12px 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcard-resize { position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; cursor: nwse-resize; opacity: 0; background: linear-gradient(135deg, transparent 50%, rgba(var(--accent-rgb), .8) 50%); border-radius: 0 0 12px 0; }
.vcard.editable:hover .vcard-resize, .vcard.selected .vcard-resize { opacity: 1; }
.dash-builder.mode-view .vcard-resize { display: none; }
.vcard.drop-target { box-shadow: 0 0 0 2px var(--accent); }
.vghost { position: absolute; border-radius: 16px; border: 2px dashed rgba(var(--accent-rgb), .7); background: rgba(var(--accent-rgb), .07); pointer-events: none; z-index: 2; }
.vis-chart { position: absolute; inset: 0; }
.vis-empty, .vis-error { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 12px; font-size: 12px; color: var(--text-3); }
.vis-empty .icon { color: rgba(var(--accent-rgb), .6); }
.vis-error { color: var(--warning); }
/* KPI */
.kpi { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 2px; container-type: inline-size; }
.kpi-value { font-size: clamp(18px, 17cqw, 40px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: linear-gradient(135deg, var(--text), color-mix(in srgb, var(--text) 70%, var(--accent))); -webkit-background-clip: text; background-clip: text; color: transparent; }
.kpi-sub { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; flex-wrap: wrap; }
.kpi-delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; padding: 1px 7px; border-radius: 20px; font-size: 11.5px; }
.kpi-delta.up { color: var(--positive); background: color-mix(in srgb, var(--positive) 14%, transparent); }
.kpi-delta.down { color: var(--negative); background: color-mix(in srgb, var(--negative) 14%, transparent); }
.kpi-target { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.kpi-spark { height: 40px; margin-top: 6px; min-height: 0; flex: 1; max-height: 70px; }
/* Tables */
.vis-table-wrap { position: absolute; inset: 0 8px 6px; overflow: auto; }
.vis-table { font-size: 12.5px; }
.vis-table th { cursor: pointer; white-space: nowrap; text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.vis-table th .icon { margin-left: 4px; }
.vis-table td { padding: 6px 10px; white-space: nowrap; }
.vis-table tbody tr { cursor: pointer; }
.vis-table tr.selected td { background: rgba(var(--accent-rgb), .14); }
.vis-table tr.dimmed td { opacity: .45; }
.vis-table.pivot td.total { font-weight: 700; background: var(--glass-2); }
/* Slicers */
.slicer { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 6px; }
.slicer-search .input { height: 28px; }
.slicer-actions { gap: 4px; }
.slicer-list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 1px; min-height: 0; }
.slicer-list.tiles { flex-direction: row; flex-wrap: wrap; align-content: flex-start; gap: 6px; }
.slicer-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 7px; cursor: pointer; font-size: 12.5px; }
.slicer-item:hover { background: var(--hover); }
.slicer-item.active { background: var(--active); }
.slicer-item input { accent-color: var(--brand-gold); }
.slicer-tile { padding: 5px 10px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--glass-2); font-size: 12px; font-weight: 600; color: var(--text-2); }
.slicer-tile.active { background: rgba(var(--accent-rgb), .18); border-color: rgba(var(--accent-rgb), .6); color: var(--text); }
.slicer-dd { width: 100%; justify-content: flex-start; }
.slicer-pop { position: absolute; top: 38px; left: 0; right: 0; bottom: auto; max-height: 300px; z-index: 30; border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; background: var(--glass-strong); }
.slicer-pop .slicer-list { max-height: 200px; }
.vcard.type-slicer { overflow: visible; }
.date-slicer, .num-slicer { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; }
.dual-range { position: relative; height: 22px; margin-top: 6px; }
.dual-range input { position: absolute; left: 0; right: 0; width: 100%; pointer-events: none; background: transparent; appearance: none; height: 22px; margin: 0; }
.dual-range input::-webkit-slider-thumb { pointer-events: auto; appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid var(--glass-solid); cursor: pointer; }
.dual-range input::-moz-range-thumb { pointer-events: auto; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--glass-solid); cursor: pointer; }
.dual-range::before { content: ''; position: absolute; left: 0; right: 0; top: 10px; height: 3px; border-radius: 3px; background: var(--line-2); }
/* Insights */
.insights { position: absolute; inset: 0 6px 6px 0; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.insight { display: flex; gap: 10px; padding: 9px 10px; border-radius: 12px; background: var(--glass-2); border: 1px solid var(--line); }
.insight-icon { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: rgba(var(--accent-rgb), .14); color: var(--accent-text); flex: none; }
.insight.positive .insight-icon { background: color-mix(in srgb, var(--positive) 16%, transparent); color: var(--positive); }
.insight.negative .insight-icon { background: color-mix(in srgb, var(--negative) 16%, transparent); color: var(--negative); }
.insight.warn .insight-icon { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); }
.insight-title { font-weight: 700; font-size: 12.5px; }
.insight-text { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.insight-basis { font-size: 10.5px; color: var(--text-3); margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.text-visual { position: absolute; inset: 0; overflow: auto; line-height: 1.45; }
.text-visual h2 { font-size: 1.6em; margin: 0 0 .2em; } .text-visual h3 { font-size: 1.3em; margin: 0 0 .2em; } .text-visual h4 { font-size: 1.1em; margin: 0 0 .2em; }
.text-visual .md-gap { height: .6em; }
/* Right panel */
.db-panel { border-radius: var(--radius-lg); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.db-tabs { padding: 4px 10px 0; margin-bottom: 0; flex: none; }
.db-panel-body { flex: 1; overflow: auto; padding: 12px; }
.type-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; }
.type-btn { height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--glass-2); color: var(--text-2); display: grid; place-items: center; transition: all var(--dur); }
.type-btn:hover { color: var(--accent-text); border-color: rgba(var(--accent-rgb), .5); transform: translateY(-1px); }
.type-btn.active { background: rgba(var(--accent-rgb), .2); color: var(--accent-text); border-color: var(--accent); }
.wells { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.well { border: 1px dashed var(--line-2); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 4px; transition: border-color var(--dur), background var(--dur); }
.well.over { border-color: var(--accent); background: rgba(var(--accent-rgb), .08); }
.well-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.well-chip { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 8px; border-radius: 8px; background: var(--glass-2); border: 1px solid var(--line); font-size: 12px; min-width: 0; }
.well-chip.missing { border-color: var(--negative); color: var(--negative); }
.well-chip .icon { color: var(--accent-text); }
.well-drop { border: 0; background: transparent; color: var(--text-3); font-size: 11.5px; text-align: left; padding: 4px; border-radius: 6px; display: inline-flex; align-items: center; gap: 4px; }
.well-drop:hover { color: var(--accent-text); background: var(--hover); }
.field-list { display: flex; flex-direction: column; gap: 4px; }
.fl-table summary { display: flex; align-items: center; gap: 6px; padding: 6px 4px; cursor: pointer; font-weight: 700; font-size: 12.5px; list-style: none; }
.fl-table summary::-webkit-details-marker { display: none; }
.fl-item { display: flex; align-items: center; gap: 7px; padding: 4px 8px 4px 18px; border-radius: 7px; font-size: 12.5px; cursor: grab; user-select: none; }
.fl-item:hover { background: var(--hover); }
.fl-item.measure .icon { color: var(--accent-text); }
.fmt-row { margin-bottom: 10px; }
.filter-section { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.filter-cards { display: flex; flex-direction: column; gap: 8px; }
.filter-card { border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: var(--glass-2); display: flex; flex-direction: column; gap: 6px; }
.fvals { max-height: 170px; overflow: auto; display: flex; flex-direction: column; gap: 1px; }
.fval { padding: 2px 4px; border-radius: 6px; }
.fval:hover { background: var(--hover); }
.focus-modal .modal-body { padding-bottom: 20px; }
.focus-body { position: relative; height: 72vh; }
.focus-body .vis-chart { position: absolute; inset: 0; }

@media (max-width: 1200px) { .db-body { grid-template-columns: 44px 1fr 290px; } .db-page-list, .db-pages-head .section-title { display: none; } }
@media (max-width: 900px) { .db-body, .dash-builder.mode-view .db-body { grid-template-columns: 1fr; } .db-pages { display: none; } .db-panel { max-height: 40vh; } .db-name { width: 160px; } }

.date-slicer { justify-content: flex-start; padding-top: 2px; }
.date-slicer .input { min-width: 0; }
@container (max-height: 70px) { .ds-note { display: none; } }
.vcard-body { container-type: size; }
/* KPI adapts to the card size */
.kpi-value { font-size: clamp(18px, min(16cqw, 34cqh), 40px); }
.kpi-sub { flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }
.kpi-sub .tiny { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@container (max-height: 110px) { .kpi-spark, .kpi-target { display: none; } .kpi-sub { margin-top: 2px; } }
@container (max-height: 60px) { .kpi-sub { display: none; } }

.vcard.popover-open { z-index: 25; overflow: visible; }
.vcard.popover-open .vcard-body { container-type: normal; }
