/* Dashboard: grid, edit mode, picker, versions, custom metrics (public/dashboards.js). */
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 15px; align-items: stretch; }
.dash-grid > .dw-cell { min-width: 0; position: relative; display: flex; flex-direction: column; }
.dash-grid > .dw-cell > .card { flex: 1; margin: 0; }
.dash.dash-grid > .dw-cell { margin-bottom: 0; }
@media (max-width: 1000px) { .dash-grid > .dw-cell { grid-column: span 12 !important; } }
.dash-top { display: flex; align-items: center; gap: 8px; }

.db-wrap { display: flex; gap: 15px; align-items: flex-start; }
.db-main { flex: 1; min-width: 0; }
.db-mode { font-size: 12px; font-weight: 600; color: var(--brand); background: var(--brand-soft); padding: 4px 9px; border-radius: 999px; margin-left: 10px; }
.db-editbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px 0; }
.db-name { font: inherit; font-size: 17px; font-weight: 650; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 260px; background: var(--surface); color: var(--text); }
.db-autosave { font-size: 12px; color: var(--muted); }
.db-note { font-size: 12.5px; color: var(--muted); }
.db-editing { outline: 2px dashed var(--line); outline-offset: 3px; border-radius: 12px; }
.db-editing.over { outline-color: var(--brand); }
.db-editing.dragging { opacity: .45; }
/* A strip above the card rather than over it, so the widget's own header
   and pickers stay readable while editing. */
.db-tools { align-self: flex-end; display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 3px; margin-bottom: 6px; box-shadow: 0 2px 8px rgba(16,24,40,.08); }
.db-tool { border: 0; background: none; font: inherit; font-size: 13px; padding: 3px 6px; border-radius: 6px; cursor: pointer; color: var(--text); }
.db-tool:hover:not(:disabled) { background: var(--hover); }
.db-tool:disabled { opacity: .4; cursor: not-allowed; }
.db-tool.danger:hover { color: var(--red); }
button.db-tool { display: inline-flex; align-items: center; justify-content: center; }
.db-grip { cursor: grab; }
select.db-width { border: 1px solid var(--line); }
.db-empty { padding: 48px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.db-empty-title { font-weight: 650; font-size: 15px; }
.db-empty-sub { color: var(--muted); font-size: 13px; max-width: 420px; }

.db-pop { position: fixed; z-index: 250; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(16,24,40,.18); width: 300px; padding: 8px; }
.db-pop-search { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; margin-bottom: 6px; }
.db-pop-list { max-height: 320px; overflow-y: auto; }
.db-pop-head { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 8px 4px; }
.db-pop-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none; font: inherit; font-size: 13.5px; padding: 7px 8px; border-radius: 7px; cursor: pointer; color: var(--text); }
.db-pop-item:hover, .db-pop-item.on { background: var(--hover); }
.db-pop-item.on { font-weight: 600; }
.db-pop-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-pop-empty { color: var(--muted); font-size: 13px; padding: 10px 8px; }
.db-pop-create { width: 100%; border: 0; border-top: 1px solid var(--line); background: none; font: inherit; font-size: 13px; color: var(--brand); padding: 9px 8px 3px; margin-top: 6px; text-align: left; cursor: pointer; }
.db-badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.db-badge.muted { background: var(--hover); color: var(--muted); }
.db-menu { padding: 6px; }
.db-menu-item { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; border: 0; background: none; font: inherit; padding: 7px 9px; border-radius: 7px; cursor: pointer; color: var(--text); }
.db-menu-item:hover:not(:disabled) { background: var(--hover); }
.db-menu-item:disabled { opacity: .5; cursor: not-allowed; }
.db-menu-item.danger .db-menu-label { color: var(--red); }
.db-menu-label { font-size: 13.5px; font-weight: 550; }
.db-menu-hint { font-size: 11.5px; color: var(--muted); }

.db-dlg.wide { max-width: 640px; }
.db-sources { display: grid; gap: 8px; }
.db-source { display: flex; flex-direction: column; gap: 2px; text-align: left; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: var(--surface); font: inherit; cursor: pointer; color: var(--text); }
.db-source.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.db-source:disabled { opacity: .55; cursor: not-allowed; }
.db-source-title { font-weight: 600; font-size: 13.5px; }
.db-source-sub { font-size: 12px; color: var(--muted); }
.db-checks { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px; margin: 8px 0; }
.db-check, .db-toggle { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 5px 4px; cursor: pointer; }
.dlg .db-check input, .dlg .db-toggle input { width: auto; }
.db-access { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.db-access-head { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 6px; }
.db-access-row { display: grid; grid-template-columns: 1fr 160px 28px; gap: 8px; align-items: center; font-size: 13.5px; }
.db-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.db-tab { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 13px; font: inherit; font-size: 13px; cursor: pointer; color: var(--text); }
.db-tab.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.db-lib { margin-top: 10px; display: flex; flex-direction: column; }
.db-lib-head { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 0 4px; }
.db-lib-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.db-lib-title { flex: 1; font-size: 13.5px; font-weight: 550; }
.db-lib-foot { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding-top: 12px; }

.db-title-el { padding: 14px 18px; display: flex; align-items: center; min-height: 60px; }
.db-title-text { font-size: 20px; font-weight: 700; }
.db-text-el { padding: 14px 18px; }
.db-text { font-size: 14px; white-space: pre-wrap; line-height: 1.5; }
.db-metric-value { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.db-metric-value.small { font-size: 20px; }
.db-metric-change { font-size: 12.5px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.db-metric-change.up { color: #1aa260; }
.db-metric-change.down { color: var(--red); }

.db-versions { width: 340px; flex: none; position: sticky; top: 12px; max-height: calc(100vh - 140px); overflow-y: auto; margin: 24px 24px 0 0; }
.db-version-list { display: flex; flex-direction: column; padding: 0 12px; }
.db-version { text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; font: inherit; padding: 10px 6px; cursor: pointer; color: var(--text); display: flex; flex-direction: column; gap: 3px; }
.db-version:hover, .db-version.on { background: var(--hover); }
.db-version-top { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.db-version-preview { padding: 6px 18px 16px; display: flex; flex-direction: column; gap: 8px; }
.db-version-widgets { margin: 0; padding-left: 18px; font-size: 13px; }
@media (max-width: 1000px) { .db-wrap { flex-direction: column; } .db-versions { width: auto; margin: 0 16px; position: static; } }

.db-metric-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.db-metric-bar input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; min-width: 240px; }
.db-formula-cell { font-size: 12.5px; color: var(--muted); max-width: 360px; }
.db-acts { white-space: nowrap; text-align: right; }
.db-acts .btn + .btn { margin-left: 4px; }
.db-formula { display: flex; flex-wrap: wrap; gap: 6px; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; align-items: center; }
.db-chip { display: inline-flex; align-items: center; border-radius: 7px; font-size: 13px; background: var(--hover); }
.db-chip.metric { background: var(--brand-soft); color: var(--brand); }
.db-chip.op, .db-chip.paren { font-weight: 700; }
.db-chip-label, .db-chip-x { border: 0; background: none; font: inherit; color: inherit; padding: 4px 7px; cursor: pointer; }
.db-chip-x { padding-left: 0; opacity: .6; }
.db-formula-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.dlg .db-formula-tools select { width: auto; flex: 1 1 200px; }
.db-op { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; width: 32px; height: 32px; font: inherit; font-size: 15px; cursor: pointer; color: var(--text); }
.dlg .db-num { width: 130px; }
.db-filter { margin-top: 8px; }
.db-filter .btn + .btn { margin-left: 6px; }
.db-preview { display: flex; align-items: baseline; gap: 12px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px; margin-top: 6px; }
.db-hist { font-size: 16px; padding: 6px 10px; }
.kebab.db-top-action { display: inline-flex; align-items: center; justify-content: center; }
.db-quick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.db-quick-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.db-check .grow { flex: 1; }
