:root{font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei",sans-serif;color:#202b3e;background:#f6f8fc;font-size:14px}*{box-sizing:border-box}body{margin:0}main{max-width:1800px;margin:0 auto;padding:28px}h1{font-size:25px;margin:12px 0}h2{font-size:18px;margin:0 0 16px}p{line-height:1.7}button,input,select,textarea{font:inherit}button{cursor:pointer;background:#fff;color:#34425b;border:1px solid #d7deea;border-radius:7px;padding:8px 13px;white-space:nowrap}button:hover{border-color:#617fe6;background:#f1f5ff}button:disabled{opacity:.5;cursor:not-allowed}.primary{background:#315bd6;color:white;border-color:#315bd6}.primary:hover{background:#244bc2;color:#fff}.danger{color:#bc3547}.link{border:0;background:transparent;padding:0;color:#315bd6}input,select,textarea{border:1px solid #d7deea;border-radius:6px;padding:8px;background:white;color:inherit;max-width:100%}textarea{resize:vertical;min-height:80px;width:100%}input:focus,select:focus,textarea:focus{outline:2px solid #a2b7fa;outline-offset:1px}.muted{color:#758298;font-size:13px}.eyebrow{color:#315bd6;letter-spacing:.14em;font-size:12px;font-weight:700}.tool-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:20px;margin-top:32px}.tool-card,.card{background:#fff;border:1px solid #dfe5ef;border-radius:12px;padding:24px}.tool-card{max-width:460px}.tool-icon{width:45px;height:45px;border-radius:10px;background:#eaf0ff;color:#315bd6;display:grid;place-items:center;font-size:22px;margin-bottom:20px}.tool-card h2{margin-bottom:8px}.tool-card button{margin-top:16px}header{display:flex;justify-content:space-between;gap:20px;align-items:center}.actions,.toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:9px}.toolbar{margin-bottom:16px}.tabs{display:flex;gap:24px;border-bottom:1px solid #dfe5ef;margin:22px 0}.tabs button{border:0;border-radius:0;background:none;padding:13px 2px;color:#68758d}.tabs button.active{color:#315bd6;border-bottom:3px solid #315bd6;font-weight:600}.table-wrap{overflow:auto;background:#fff;border:1px solid #dfe5ef;border-radius:10px;max-height:65vh}table{border-collapse:collapse;width:100%;text-align:left}th{text-align:center;font-weight:500;color:#68758d;background:#f7f9fc;position:sticky;top:0;z-index:1}td,th{padding:12px;border-bottom:1px solid #e9edf4;vertical-align:middle;white-space:nowrap}td{text-align:left}td input,td textarea{min-width:135px}td textarea{min-width:240px;min-height:68px}td select{min-width:140px}td .link{white-space:normal}td .error{max-width:220px;white-space:normal}.tag{display:inline-block;border-radius:5px;background:#eef2fb;color:#4665ac;padding:4px 7px;margin:2px;font-size:12px}.error{color:#ba3548;font-size:12px;line-height:1.5}.status{font-size:12px;color:#667388}.status.ok{color:#16805b}.empty{text-align:center;padding:60px 20px;color:#758298}.empty h2{color:#34425b}.form{display:grid;gap:16px}.form label{display:grid;gap:7px}.form .inline{display:flex;align-items:center;gap:8px}.two{display:grid;grid-template-columns:1fr 1fr;gap:16px}.mono,pre{font-family:ui-monospace,SFMono-Regular,Consolas,monospace}pre{background:#f3f6fb;border:1px solid #e0e6ef;padding:16px;border-radius:8px;white-space:pre-wrap;word-break:break-word;font-size:13px;max-height:400px;overflow:auto}.list-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 0;border-bottom:1px solid #edf0f5}.list-row p{margin:5px 0}dialog{width:min(900px,94vw);max-height:90vh;border:1px solid #d7deea;border-radius:13px;padding:24px;box-shadow:0 20px 80px #1d31532e}dialog::backdrop{background:#17233c55}.dialog-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:18px}.dialog-head h2{margin:0}#modalActions{justify-content:flex-end;margin-top:24px;position:sticky;bottom:-24px;background:white;padding:14px 0}#notice{position:fixed;top:16px;right:24px;max-width:min(620px,calc(100vw - 32px));z-index:100;background:#fff;color:#25262b;border-radius:16px;padding:16px 20px;display:none;align-items:center;gap:12px;box-shadow:0 6px 24px #1d233314;font-size:16px;font-weight:400;line-height:1.5;white-space:pre-wrap;overflow-wrap:anywhere;pointer-events:none}#notice.show{display:flex}#notice .notice-icon{display:inline-flex;align-items:center;justify-content:center;flex:0 0 24px;width:24px;height:24px;border-radius:50%;background:#52c41a;color:white}#notice .notice-icon svg{width:16px;height:16px}#notice.fail .notice-icon{background:#f04438}#notice .notice-message{min-width:0}
.help{padding:12px 16px;background:#eef3ff;color:#526b99;border-radius:8px;line-height:1.7;margin-bottom:16px}.column-row{display:grid;grid-template-columns:24px minmax(180px,1fr) minmax(160px,320px) auto auto;gap:10px;align-items:center;margin:9px 0}.count{color:#315bd6;font-weight:600}small{line-height:1.6}.sql-chip{display:flex;align-items:center;gap:8px;margin-bottom:8px}@media(max-width:900px){main{padding:16px}header{display:block}.two{grid-template-columns:1fr}.column-row{grid-template-columns:24px minmax(120px,1fr) minmax(120px,220px) auto auto}.tabs{gap:12px}}
td input[type=checkbox],th input[type=checkbox]{min-width:0;width:16px;height:16px}td:first-child,th:first-child{white-space:nowrap}#saveState{min-height:20px}
.project-bar{display:flex;align-items:center;flex-wrap:wrap;gap:12px;background:#fff;border:1px solid #dfe5ef;border-radius:10px;padding:16px;margin:16px 0 10px}.project-bar>label{display:flex;align-items:center;gap:12px;font-weight:600}.project-bar select{min-width:220px}input:disabled,select:disabled,textarea:disabled,input[readonly]{background:#eef1f5;color:#8993a3;border-color:#dfe3e9;cursor:not-allowed}.search-select{display:inline-flex;vertical-align:middle;flex-direction:column;gap:5px;min-width:140px;max-width:100%;font-weight:400}.search-select .select-search{font-size:12px;padding:6px 9px;min-width:0;width:100%;background:#fafbfe}.search-select select{width:100%}.select-search-hint{font-size:11px;white-space:normal;max-width:230px}.form label>.search-select{display:flex;width:100%}#projectListQuery{width:100%;margin-bottom:12px}#projectListRows{max-height:55vh;overflow:auto}#projectListRows .list-row>div:first-child{min-width:0;overflow-wrap:anywhere}#projectListRows .list-row .actions{flex-shrink:0}@media(max-width:600px){.project-bar>label{width:100%}.project-bar .search-select{flex:1;min-width:0}.project-bar select{min-width:0}#projectListRows .list-row{align-items:flex-start;flex-direction:column}}
dialog.right-drawer{position:fixed;inset:0 0 0 auto;margin:0;width:min(820px,100vw);height:100vh;height:100dvh;max-height:100vh;max-height:100dvh;max-width:100vw;border:0;border-left:1px solid #dfe5ef;border-radius:0;padding:0;box-shadow:-12px 0 50px #1d315329}dialog.right-drawer[open]{display:flex;flex-direction:column}.right-drawer .dialog-head{flex-shrink:0;padding:20px 24px;border-bottom:1px solid #e9edf4;margin:0}.right-drawer #modalBody{padding:24px;overflow:auto;flex:1;min-height:0}.right-drawer #modalActions{position:static;flex-shrink:0;margin:0;padding:16px 24px;border-top:1px solid #e9edf4}.detail-name{font-weight:600;text-align:left;font-size:14px}.detail-grid{display:grid;grid-template-columns:110px 1fr;gap:12px;overflow-wrap:anywhere}.detail-grid dt{color:#758298}.detail-grid dd{margin:0}.right-drawer .table-wrap{max-height:45vh}.template-pick{display:flex;align-items:flex-start;gap:12px}.template-pick input{margin-top:5px}.question-cell{white-space:normal;min-width:220px;max-width:380px}
/* Compact question actions and searchable filters. */
.question-toolbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 12px}.set-picker{display:flex;align-items:center;gap:8px;min-width:0}.set-picker select{max-width:290px}.question-primary-actions{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:wrap}.question-filters{gap:10px;margin-bottom:12px}.question-filters>input{width:230px}.question-filters select{min-width:120px}.question-toolbar button,.question-toolbar summary,.question-filters input,.question-filters select{padding:7px 10px;font-size:13px}.action-menu{position:relative}.action-menu summary{list-style:none;border:1px solid #d7deea;border-radius:7px;padding:8px 12px;cursor:pointer;background:white;white-space:nowrap}.action-menu summary::-webkit-details-marker{display:none}.menu-items{position:absolute;top:calc(100% + 6px);right:0;z-index:20;min-width:170px;background:white;border:1px solid #dfe5ef;border-radius:8px;padding:6px;box-shadow:0 8px 25px #233c7220;display:grid;gap:3px}.menu-items button{border:0;text-align:left}.menu-items button:hover{background:#f1f5ff}.list-pagination{display:flex;justify-content:flex-end;align-items:center;gap:10px;flex-wrap:wrap;margin:12px 0;color:#758298;font-size:12px}.list-pagination>span:first-child{margin-right:auto}.list-pagination label{display:flex;align-items:center;gap:5px}.list-pagination button,.list-pagination select{font-size:12px;padding:5px 9px}.list-pagination select{width:auto;min-width:0}[data-page-list]>[hidden]{display:none!important}.template-row{align-items:center}.template-row>input[type=checkbox]{width:16px;height:16px;flex-shrink:0;accent-color:#315bd6}.template-copy{flex:1;min-width:0}.template-copy code{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}.template-row .actions{flex-shrink:0}.template-select-all{display:flex;align-items:center;gap:10px;padding-bottom:12px;border-bottom:1px solid #e9edf4}.template-select-all input{accent-color:#315bd6}.template-list-card{padding:16px 20px}.sql-editor{position:relative;border:1px solid #d7deea;border-radius:8px;background:#f8fafc;overflow:hidden}.sql-editor:focus-within{outline:2px solid #a2b7fa;outline-offset:1px}.sql-editor .sql-highlight,.sql-editor textarea[data-sql-editor]{box-sizing:border-box;font:13px/1.65 ui-monospace,SFMono-Regular,Consolas,monospace;tab-size:4;letter-spacing:normal;padding:16px;border:0;border-radius:0;margin:0;white-space:pre;word-break:normal;overflow-wrap:normal;text-align:left}.sql-editor .sql-highlight{position:absolute;inset:0;overflow:hidden;max-height:none;background:transparent;pointer-events:none;color:#26344c}.sql-editor textarea[data-sql-editor]{display:block;position:relative;z-index:1;width:100%;height:350px;min-height:200px;max-height:70vh;resize:vertical;background:transparent;color:transparent;-webkit-text-fill-color:transparent;caret-color:#1f2937;outline:none;overflow:auto}.sql-editor textarea[data-sql-editor]::selection{background:#a8c4ff66}.sql-editor textarea[data-sql-editor]::placeholder{color:#8894a8;-webkit-text-fill-color:#8894a8}.sql-keyword{color:#7945c7;font-weight:600}.sql-function{color:#1264ae}.sql-string{color:#19815e}.sql-comment{color:#81909d;font-style:italic}.sql-number{color:#b16a0e}.sql-identifier{color:#795734}.sql-parameter{color:#c44475;font-weight:600}pre.sql-code{font-size:13px;line-height:1.65;background:#f8fafc}.compact-search{position:relative;padding-left:28px;min-width:0}.compact-search .select-search{display:none;position:absolute;top:calc(100% + 5px);left:0;z-index:22;box-shadow:0 4px 16px #233c7220;min-width:190px;background:white}.compact-search.search-open .select-search{display:block}.compact-search .search-toggle{position:absolute;left:0;top:0;height:100%;width:25px;padding:0;border:0;background:transparent;color:#60718a}.compact-search .select-search-hint{position:absolute;left:0;top:calc(100% + 36px);z-index:22;background:white;width:100%;padding:4px;display:none}.compact-search.search-open .select-search-hint:not([hidden]){display:block}.compact-search.has-search .search-toggle{color:#315bd6;background:#eaf0ff;border-radius:4px}@media(max-width:1000px){.question-primary-actions{margin-left:0}.template-row{flex-wrap:wrap}.template-row .actions{margin-left:auto}.question-filters>input{width:190px}}@media(forced-colors:active){.sql-editor .sql-highlight{display:none}.sql-editor textarea[data-sql-editor]{color:CanvasText;-webkit-text-fill-color:CanvasText}}

/* Compact workspace heading and editable project picker. */
header.workspace-header{display:flex;align-items:center;gap:12px;min-width:0}
.workspace-breadcrumb{display:flex;align-items:center;gap:8px;min-width:0;white-space:nowrap}
.workspace-breadcrumb h1{font-size:16px;margin:0;line-height:1.5}
.workspace-breadcrumb>.link{font-size:15px}
.workspace-breadcrumb>span{color:#8995a8}
.workspace-header>button{padding:7px 10px;font-size:13px}
.tool-help{padding:0;width:20px;height:20px;border-radius:50%;font-size:12px;color:#758298;flex:none}
.project-bar.compact-project-bar{flex-wrap:nowrap;gap:8px;padding:8px 10px;margin:12px 0 8px}
.project-bar.compact-project-bar>label{width:auto;flex:none;font-size:13px;font-weight:500}
.compact-project-bar>button{padding:7px 9px;font-size:13px}
.project-combo{position:relative;flex:1;min-width:0;max-width:360px}
.project-combo>input{width:100%;height:34px;padding:6px 26px 6px 9px;font-size:13px;text-overflow:ellipsis}
.combo-chevron{position:absolute;right:10px;top:7px;color:#758298;pointer-events:none}
.project-options{position:absolute;top:calc(100% + 5px);left:0;right:0;min-width:180px;max-height:260px;overflow-y:auto;background:#fff;border:1px solid #d7deea;border-radius:7px;box-shadow:0 8px 24px #24365226;z-index:20;padding:4px}
.project-options [role=option]{padding:8px;border-radius:4px;cursor:pointer;overflow-wrap:anywhere}
.project-options [role=option]:hover,.project-options [role=option].active{background:#edf2ff}
.project-options [aria-selected=true]{color:#315bd6;font-weight:600}
.project-no-match{padding:10px;color:#758298;font-size:13px}
@media(max-width:420px){.workspace-breadcrumb{gap:5px}.workspace-breadcrumb h1{font-size:14px}.workspace-breadcrumb>.link{font-size:13px}.workspace-header{gap:6px}.workspace-header>button{font-size:12px;padding:6px}.project-bar.compact-project-bar{gap:6px;padding:8px}.compact-project-bar>button{padding:7px 6px}}

.editable-select{display:inline-block;position:relative;min-width:100px;max-width:100%;vertical-align:middle}
.editable-select>select[hidden]{display:none!important}
.editable-select>input{width:100%;padding-right:27px;text-overflow:ellipsis;min-width:0}
.editable-select>.combo-arrow{position:absolute;right:9px;top:50%;transform:translateY(-50%);pointer-events:none;color:#758298}
.editable-select>input:disabled{background:#edf0f5;color:#8a94a5;cursor:not-allowed}
.editable-select-options{position:fixed;inset:auto;margin:0;padding:4px;background:white;color:#202b3e;border:1px solid #d7deea;border-radius:7px;box-shadow:0 8px 24px #24365226;overflow:auto;z-index:200;font-size:14px;white-space:normal}
.editable-select-options[hidden]{display:none}
.editable-select-options [role=option]{padding:8px;border-radius:4px;cursor:pointer;overflow-wrap:anywhere}
.editable-select-options [role=option]:hover,.editable-select-options [role=option].active{background:#edf2ff}
:is(.editable-select-options,.project-options,.metric-dropdown) [role=option][aria-selected=true]{position:relative;background:#edf2ff;color:#315bd6;font-weight:600;padding-right:36px}
:is(.editable-select-options,.project-options,.metric-dropdown) .option-check{position:absolute;right:12px;top:50%;transform:translateY(-50%);color:#315bd6;font-size:17px;line-height:1}
.project-options [aria-selected=true],.metric-dropdown [aria-selected=true]{background:#edf2ff}
.combo-empty{padding:10px;color:#758298;font-size:13px}
.form .editable-select{display:block;width:100%}td .editable-select{min-width:140px}
.question-filters .editable-select{width:170px}.question-toolbar .editable-select{width:220px}
.list-pagination .editable-select{min-width:70px;width:75px}

.list-pagination{display:flex;align-items:center;justify-content:flex-end;gap:10px;flex-wrap:wrap;padding:16px 0;color:#202b3e;font-size:14px}
.list-pagination [data-page-summary]{margin-right:6px;white-space:nowrap}
.list-pagination .page-numbers{display:flex;align-items:center;gap:5px}
.list-pagination .page-numbers button,.list-pagination .page-arrow{height:34px;min-width:34px;padding:0 8px;border:1px solid transparent;border-radius:8px;background:transparent;color:inherit}
.list-pagination .page-numbers button[aria-current=page]{border-color:#7960ff;color:#7054f4;font-weight:600;background:white}
.list-pagination .page-numbers button:hover,.list-pagination .page-arrow:hover:not(:disabled){background:#f1eeff;color:#7054f4}
.list-pagination .page-arrow{font-size:25px;line-height:1}.list-pagination .page-arrow:disabled{color:#9299a8;background:transparent}
.list-pagination .page-ellipsis{padding:0 5px;color:#9299a8}
.list-pagination .editable-select{width:110px;min-width:110px;margin-left:10px}
.list-pagination .editable-select>input{height:34px;background:white;border-radius:8px}
.list-pagination .page-jump{display:flex;align-items:center;gap:8px;white-space:nowrap}
.list-pagination .page-jump input{width:54px;height:34px;min-width:0;text-align:center;border-radius:8px;appearance:textfield;-moz-appearance:textfield}
.list-pagination .page-jump input::-webkit-inner-spin-button,.list-pagination .page-jump input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
@media(max-width:600px){.list-pagination{gap:6px}.list-pagination .editable-select{margin-left:0}.list-pagination .page-numbers{gap:2px}}

.list-pagination [data-page-summary]{margin-right:auto}
.confirm-popover{position:fixed;inset:auto;margin:0;width:310px;max-width:calc(100vw - 16px);padding:14px;border:1px solid #d7deea;border-radius:9px;background:white;color:#202b3e;box-shadow:0 8px 30px #24365230;z-index:300}
.confirm-popover p{margin:0 0 12px;line-height:1.6;font-size:13px}.confirm-popover .actions{justify-content:flex-end}
.metric-badge{display:inline-block;padding:4px 9px;border-radius:5px;font-size:13px;white-space:normal;vertical-align:middle}
.metric-description{white-space:normal;min-width:180px;max-width:420px}
.sql-section-heading{display:flex;align-items:center;gap:12px;margin:18px 0 12px}.sql-section-heading h3{margin:0}

.editable-select-options [role=option].active{outline:2px solid #7960ff;outline-offset:-2px}

.template-summary{min-width:260px;max-width:480px;white-space:normal}.template-summary code{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:450px}.template-metrics{min-width:160px;max-width:280px;white-space:normal}.template-metrics .metric-badge{margin:2px}.metric-options{display:flex;flex-wrap:wrap;gap:8px;max-height:220px;overflow:auto}.form .metric-options label{display:flex;align-items:center;gap:5px}.form .metric-options label[hidden]{display:none}

.metric-picker{display:grid;gap:7px}.metric-picker-control{position:relative}.metric-picker-control>input{width:100%;padding-right:30px}.metric-picker-control>span{position:absolute;right:11px;top:9px;pointer-events:none;color:#758298}
.metric-dropdown{position:absolute;left:0;right:0;top:calc(100% + 5px);max-height:230px;overflow:auto;padding:5px;background:#fff;border:1px solid #d7deea;border-radius:7px;box-shadow:0 8px 24px #24365226;z-index:30}
.metric-batch-actions{position:sticky;top:-5px;z-index:1;display:flex;align-items:center;gap:12px;padding:8px 7px;background:#fff;border-bottom:1px solid #e5eaf2}
.metric-batch-actions .muted{margin-left:auto;font-size:12px;white-space:nowrap}
.metric-batch-actions button:disabled{opacity:.45;cursor:default}
.metric-dropdown[hidden]{display:none}.metric-dropdown [role=option]{display:flex;align-items:center;gap:9px;padding:7px;border-radius:5px;cursor:pointer}.metric-dropdown [role=option]:hover,.metric-dropdown [role=option].active{background:#edf2ff}.metric-check{width:17px;height:17px;border:1px solid #b9c4d6;border-radius:3px;display:inline-flex;align-items:center;justify-content:center;color:#315bd6;font-size:13px}.metric-dropdown [aria-selected=true] .metric-check{border-color:#315bd6;background:#eef3ff}
.metric-selected{display:flex;flex-wrap:wrap;gap:7px}.metric-selected[hidden]{display:none}.metric-selected .metric-badge{display:inline-flex;align-items:center;gap:6px}.metric-selected button{border:0;padding:0 3px;background:transparent;color:inherit;font-size:16px;line-height:1}.metric-selected button:hover{background:#ffffff80}

/* Spreadsheet-style question editor. */
.question-sheet{max-height:65vh;border-radius:8px}.question-sheet table{width:max-content;min-width:100%;table-layout:fixed}
.question-sheet thead th{z-index:6;background:#f5f7fc;border-right:1px solid #e1e6f0;font-size:13px;font-weight:600}.question-sheet th small{display:block;color:#8591a5;font-weight:400}
.question-sheet tbody th{position:sticky;top:auto;left:0;z-index:2;background:#f7f9fc;min-width:64px;font-size:12px;font-weight:400}
.question-sheet td[data-cell]{position:relative;min-width:170px;max-width:330px;width:220px;height:70px;white-space:pre-wrap;border:1px solid #e5e9f1;padding:10px;cursor:cell;outline:none;vertical-align:middle;user-select:none}
.question-sheet td.grid-selected{background:#eef3ff;box-shadow:inset 0 0 0 1px #86a6fb}.question-sheet td[data-cell]:focus{box-shadow:inset 0 0 0 2px #315bd6}
.grid-cell-text{display:block;white-space:pre-wrap;overflow-wrap:anywhere;max-height:135px;overflow:auto}.question-sheet td.grid-unused{color:#a4adbb;background:#fafbfd}.question-sheet td.grid-unused.grid-selected{background:#eef3ff}
.grid-fill-handle{position:absolute;right:-1px;bottom:-1px;width:8px;height:8px;background:#315bd6;border:1px solid white;cursor:crosshair;z-index:3}
.question-sheet td.grid-editing{padding:5px;cursor:auto;user-select:text;min-width:260px}.question-sheet td.grid-editing>input,.question-sheet td.grid-editing>textarea,.question-sheet td.grid-editing>select{width:100%;min-width:160px}.question-sheet td.grid-editing>textarea{min-height:105px}
.grid-template-editor{width:310px;max-width:70vw;display:grid;gap:8px}.grid-template-editor input{width:100%}.grid-template-choices{max-height:200px;overflow:auto;display:grid;gap:3px}.grid-template-choices button{position:relative;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;padding-right:30px;border:0}.grid-template-choices button[aria-pressed=true]{background:#edf2ff;color:#315bd6;font-weight:600}.grid-template-choices button span{position:absolute;right:10px;top:10px}.grid-template-order{font-size:12px;max-height:160px;overflow:auto}.grid-template-order-row{display:flex;align-items:center;gap:12px;min-width:0;text-align:left}.grid-template-order-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.grid-template-order-actions{display:flex;flex:0 0 auto;align-items:center;gap:4px;margin-left:auto}.grid-template-order button{padding:2px 6px;margin:2px 0}
.question-sheet .grid-status{min-width:220px;max-width:290px;white-space:normal}.grid-status .actions{margin-top:8px}.grid-status button{font-size:12px;padding:3px 6px}.grid-empty{padding:20px}.grid-footer{display:flex;align-items:center;justify-content:flex-end;gap:12px;margin-top:12px}.grid-footer-left{display:flex;align-items:center;gap:16px;margin-right:auto}.grid-footer{flex-wrap:wrap}.grid-append-rows{display:flex;align-items:center;gap:7px}.grid-append-rows button{border:0;background:transparent;padding:2px 6px;font-size:24px;font-weight:600;line-height:28px}.grid-append-rows input{width:76px;padding:4px 8px;text-align:center}

/* Keep the workspace and question controls compact. */
#workspace{max-width:none;padding:6px 14px}
#workspace .tabs{margin:4px 0 12px}
#workspace .tabs button{padding:9px 2px}
.question-toolbar{gap:8px}
.question-toolbar .set-picker{flex-shrink:0;white-space:nowrap}
.question-toolbar .question-filters{display:flex;align-items:center;flex-wrap:nowrap;gap:8px;margin:0;min-width:0}
.question-toolbar .question-filters>input{width:170px;min-width:100px}
.question-toolbar .question-filters .editable-select{width:120px;min-width:100px}
.question-toolbar .question-filters .muted{white-space:nowrap;font-size:12px}
.question-toolbar .set-picker .editable-select{width:200px}
@media(max-width:1100px){.question-toolbar .question-filters{flex-wrap:wrap}.question-toolbar .question-primary-actions{margin-left:0}}

/* Minimal toolbox launcher: the entire compact card is the entry point. */
#home{max-width:none;padding:12px 14px}
#home h1{font-size:16px;line-height:24px;margin:0 0 10px}
#home .tool-cards{display:flex;flex-wrap:wrap;gap:8px;margin:0}
#home .tool-card{display:flex;align-items:center;gap:9px;width:260px;max-width:100%;padding:10px 12px;border-radius:7px;text-align:left;background:#fff}
#home .tool-card:hover{background:#f1f5ff;border-color:#617fe6}
#home .tool-card:focus-visible{outline:2px solid #315bd6;outline-offset:2px}
#home .tool-icon{flex:none;width:26px;height:26px;margin:0;border-radius:5px;font-size:14px}
#home .tool-name{font-size:14px;font-weight:500;white-space:normal}
#home .tool-arrow{margin-left:auto;color:#758298;font-size:16px}

#home a.tool-card{border:1px solid #dfe5ef;color:inherit;text-decoration:none}
#home a.tool-card:hover{border-color:#617fe6}

header.workspace-header-inline{justify-content:flex-start;flex-wrap:nowrap;gap:18px;height:40px;padding:3px 0;border-bottom:1px solid #e4e8ef;margin-bottom:6px}
.workspace-header-inline .workspace-breadcrumb{flex:0 1 auto}.workspace-header-inline .workspace-breadcrumb h1{font-size:18px;overflow:hidden;text-overflow:ellipsis}.workspace-header-inline .workspace-breadcrumb>.link{flex:none;color:#65728a;font-size:14px}.workspace-header-inline .workspace-breadcrumb>.link:hover{color:#315bd6}
.workspace-divider{height:20px;width:1px;background:#dfe5ee;flex:none}.workspace-header-inline .project-combo{flex:0 1 210px;max-width:220px;min-width:100px}.workspace-header-inline .project-combo>input{height:36px;background:transparent;border-color:transparent;font-size:14px}.workspace-header-inline .project-combo>input:hover{background:#edf0f5}.workspace-header-inline .project-combo>input:focus{background:#fff}
.workspace-header-actions{margin-left:auto;display:flex;align-items:center;gap:12px;flex:none}.workspace-header-actions #save{padding:7px 12px;font-size:13px}.workspace-header-actions summary{display:flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;border:0;background:transparent;font-size:24px;color:#65728a}.workspace-header-actions summary:hover,.workspace-header-actions details[open]>summary{background:#edf0f5}.workspace-header-actions .tool-help{width:24px;height:24px;font-size:13px;background:transparent}.workspace-header-actions .menu-items{min-width:150px}
@media(max-width:760px){header.workspace-header-inline{gap:10px}.workspace-header-inline .workspace-breadcrumb h1{font-size:15px;max-width:170px}.workspace-header-inline .project-combo{flex-basis:150px}.workspace-header-actions{gap:6px}}
@media(max-width:520px){header.workspace-header-inline{gap:7px}.workspace-header-inline .workspace-breadcrumb{flex:1;min-width:65px}.workspace-header-inline .workspace-breadcrumb h1{font-size:14px}.workspace-header-inline .workspace-breadcrumb>.link,.workspace-header-inline .workspace-breadcrumb>span{display:none}.workspace-header-inline .project-combo{min-width:85px;flex-basis:110px}.workspace-header-actions #save{padding:6px;font-size:12px}.workspace-header-actions .tool-help{width:20px;height:20px}}

/* Visible navigation affordances, with save feedback next to its action. */
.workspace-header-inline .workspace-breadcrumb>.link{color:#315bd6;padding:5px 7px;border-radius:5px;text-decoration:underline;text-decoration-color:#b5c5f3;text-underline-offset:4px}.workspace-header-inline .workspace-breadcrumb>.link:hover{background:#eaf0ff;text-decoration-color:currentColor}
.workspace-header-inline .project-combo>input{background:#fff;border:1px solid #d7deea;cursor:pointer;padding-left:12px}.workspace-header-inline .project-combo>input:hover{background:#fff;border-color:#8ca5ed}.workspace-header-inline .project-combo>input:focus{cursor:text}.workspace-header-inline .combo-chevron{color:#315bd6}
.workspace-save-state{font-size:12px;max-width:120px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#758298}
@media(max-width:760px){.workspace-save-state{max-width:70px}.workspace-header-actions{gap:7px}}
@media(max-width:520px){.workspace-header-inline .workspace-breadcrumb>.link{display:inline-block;font-size:12px}.workspace-header-inline .workspace-breadcrumb h1{display:none}.workspace-header-inline .workspace-breadcrumb{flex:0 0 auto;min-width:0}.workspace-save-state{max-width:48px;font-size:11px}}

/* Fit the frame to resized columns; wide tables still scroll within the page. */
.question-sheet{width:max-content;max-width:100%}
/* Explicit colgroup widths allow resizing both below and above default widths. */
.question-sheet table{width:auto;min-width:0;table-layout:fixed}
.question-sheet td[data-cell],.question-sheet td.grid-editing,.question-sheet .grid-status,.question-sheet tbody th{width:auto;min-width:0;max-width:none;overflow-wrap:anywhere}
.question-sheet thead th{padding-right:14px;white-space:normal;overflow-wrap:anywhere}
.grid-column-resizer{position:absolute;right:0;top:0;bottom:0;width:8px;cursor:col-resize;touch-action:none;z-index:4;outline:none}
.grid-column-resizer:hover,.grid-column-resizer:focus{background:#315bd633;border-right:2px solid #315bd6}
.grid-resizing,.grid-resizing *{cursor:col-resize!important;user-select:none!important}
.question-sheet td.grid-editing>input,.question-sheet td.grid-editing>textarea,.question-sheet td.grid-editing>select,.question-sheet td .editable-select{min-width:0;max-width:100%}
.question-sheet .grid-template-editor{width:100%;min-width:0;max-width:100%}

.question-sheet .grid-cell-text.grid-placeholder{color:#98a2b3;font-weight:400}
.question-sheet td.grid-editing input::placeholder,.question-sheet td.grid-editing textarea::placeholder{color:#98a2b3;opacity:1}

/* SQL selection stays outside table layout, even inside the scrolling sheet. */
.question-sheet .grid-template-editor.grid-template-popover{position:fixed;inset:auto;margin:0;padding:12px;max-width:calc(100vw - 16px);min-width:0;border:1px solid #d7deea;border-radius:8px;background:#fff;color:#202b3e;box-shadow:0 8px 24px #24365226;overflow:auto;z-index:200;white-space:normal}
.grid-template-popover .grid-template-choices,.grid-template-popover .grid-template-order{min-height:0}

/* Row height is user-controlled; content and editors scroll within the row. */
.question-sheet tbody tr{height:var(--grid-row-height,90px)}
.question-sheet tbody td,.question-sheet tbody th{height:var(--grid-row-height,90px)}
.question-sheet tbody td{position:relative}
.question-sheet .grid-cell-text,.question-sheet .grid-status-content{position:absolute;inset:10px;max-height:none;overflow:auto;align-content:safe center}
.question-sheet td.grid-editing>input,.question-sheet td.grid-editing>textarea,.question-sheet td.grid-editing>.editable-select{position:absolute;inset:5px;width:calc(100% - 10px);min-height:0;max-height:none;margin:0}
.question-sheet td.grid-editing>textarea{height:calc(100% - 10px);resize:none}
.question-sheet td.grid-editing>input{height:34px}
.question-sheet td.grid-editing>.editable-select{height:34px}
.grid-row-resizer{position:absolute;left:0;right:0;bottom:-3px;height:8px;z-index:5;cursor:row-resize;touch-action:none;outline:none}
.grid-row-resizer:hover,.grid-row-resizer:focus{background:#315bd633;border-bottom:2px solid #315bd6}
.grid-row-resizing,.grid-row-resizing *{cursor:row-resize!important;user-select:none!important}

/* Shared compact option presentation across toolbox pickers. */
:is(.editable-select-options,.project-options,.metric-dropdown) [role=option],.question-sheet .grid-template-choices button{font-size:12px;line-height:20px;padding-top:6px;padding-bottom:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.metric-dropdown [role=option]{display:block}
.metric-dropdown [role=option] .metric-badge{display:block;max-width:100%;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.question-sheet .grid-template-choices{display:block}
.question-sheet .grid-template-choices button{display:block;width:100%;min-width:0;text-align:left}

/* Edit text in place, using the cell itself as the focus boundary. */
.question-sheet td.grid-editing:focus-within{background:#fff;box-shadow:inset 0 0 0 2px #315bd6}
.question-sheet td.grid-editing>input,.question-sheet td.grid-editing>textarea{inset:10px;width:calc(100% - 20px);padding:0;border:0;border-radius:0;background:transparent;outline:none;box-shadow:none;font:inherit;line-height:20px}
.question-sheet td.grid-editing>input{height:24px}
.question-sheet td.grid-editing>textarea{height:calc(100% - 20px)}

.grid-valid-variable{color:#067647}
.grid-invalid-variable{color:#d92d20}
.question-sheet .grid-question-highlight{position:absolute;inset:10px;overflow:auto;pointer-events:none;white-space:pre-wrap;overflow-wrap:break-word;font:inherit;line-height:20px;scrollbar-width:none}
.question-sheet td.grid-editing>textarea.grid-question-input{color:transparent;-webkit-text-fill-color:transparent;caret-color:#202b3e;background:transparent;white-space:pre-wrap;overflow-wrap:break-word}
.question-sheet td.grid-editing>textarea.grid-question-input::placeholder{-webkit-text-fill-color:#98a2b3}
.grid-variable-menu{position:fixed;inset:auto;margin:0;padding:4px;border:1px solid #d7deea;border-radius:7px;background:white;color:#202b3e;box-shadow:0 8px 24px #24365226;overflow:auto;z-index:210}
.grid-variable-menu button{display:block;width:100%;border:0;border-radius:4px;padding:6px 9px;font-size:12px;line-height:20px;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.grid-variable-menu button.active,.grid-variable-menu button:hover{background:#edf2ff;color:#315bd6}
.grid-variable-menu.sql-insert-menu{padding:0;overflow:hidden}
.sql-insert-menu:popover-open{display:flex;flex-direction:column}
.sql-insert-tabs{display:flex;flex:none;border-bottom:1px solid #d7deea;padding:0 8px;gap:12px}
.sql-insert-tabs button{width:auto;border-radius:0;padding:9px 10px;border-bottom:2px solid transparent;color:#758298}
.grid-variable-menu .sql-insert-tabs button,.grid-variable-menu .sql-insert-tabs button:hover{background:transparent}
.sql-insert-tabs button[aria-selected=true]{border-bottom-color:#315bd6;color:#315bd6;font-weight:600}
.sql-insert-panel{min-height:0;min-width:0;overflow:auto;padding:4px;overscroll-behavior:contain}
.sql-insert-panel button{display:flex;align-items:center;gap:8px}
.sql-insert-panel button small{flex:0 1 auto;min-width:0;max-width:45%;overflow:hidden;text-overflow:ellipsis;font-size:11px;color:#758298}
.sql-insert-panel button span{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis}
@media(forced-colors:active){.grid-question-highlight{display:none}.question-sheet td.grid-editing>textarea.grid-question-input{color:CanvasText;-webkit-text-fill-color:CanvasText}}

.grid-variable-title{position:sticky;top:-4px;z-index:1;background:#fff;padding:7px 9px;margin-bottom:3px;border-bottom:1px solid #e9edf4;font-size:12px;font-weight:600;color:#68758d;line-height:20px}

/* Spreadsheet row selection and context actions. */
.question-sheet [data-grid-row]{cursor:default;user-select:none;outline-offset:-2px}
.question-sheet [data-grid-row].grid-row-selected{background:#dfe8ff;color:#244bc2;box-shadow:inset 3px 0 #315bd6}
.grid-row-menu{position:fixed;z-index:250;width:240px;max-width:calc(100vw - 16px);max-height:calc(100vh - 16px);overflow:auto;padding:6px;background:#fff;color:#202b3e;border:1px solid #d7deea;border-radius:9px;box-shadow:0 8px 28px #24365226}
.grid-row-menu-title{padding:7px 10px;font-size:12px;color:#758298}
.grid-row-menu button{display:flex;align-items:center;justify-content:space-between;gap:16px;width:100%;border:0;border-radius:5px;padding:8px 10px;text-align:left}
.grid-row-menu button:hover,.grid-row-menu button:focus-visible{background:#edf2ff;color:#315bd6}
.grid-row-menu small{color:#8792a5;font-size:12px}
.grid-row-menu hr{border:0;border-top:1px solid #e9edf4;margin:5px 0}
.grid-row-menu-insert{position:relative;margin:2px 0}
.grid-row-menu-insert button{min-height:40px}
.grid-row-menu-insert input{position:absolute;right:32px;top:50%;transform:translateY(-50%);width:68px;padding:4px 6px;font-size:13px}
.grid-row-menu-insert:focus-within{background:#edf2ff;border-radius:5px}
.grid-row-menu [data-row-action=delete]{color:#bc3547}

.template-reference{margin-bottom:10px}.template-reference>.link{text-align:left;white-space:normal}.template-reference-rows{display:flex;flex-wrap:wrap;gap:6px 12px;margin-top:5px}.template-reference-rows .link{font-size:12px}

.library-filter-pickers{display:contents}
.template-multiselect .metric-filter-clear{position:absolute;right:3px;top:50%;transform:translateY(-50%);width:22px;height:22px;padding:0;border:0;border-radius:4px;background:#fff;color:#55647a;cursor:pointer}
.template-multiselect .metric-filter-clear:hover{background:#edf2ff;color:#315bd6}
.template-filters input{width:180px}.template-filters select{max-width:220px}
/* Shared SQL controls: gutter and copy button stay outside the selectable SQL. */
.sql-editor .sql-highlight,.sql-editor textarea[data-sql-editor],.sql-view>pre.sql-code{padding:16px 48px 16px 64px}
.sql-line-numbers{position:absolute;inset:0 auto 0 0;width:52px;overflow:hidden;pointer-events:none;user-select:none;z-index:2;background:#f0f3f8;border-right:1px solid #e0e6ef;color:#8b95a5}
.sql-line-numbers>div{padding:16px 10px;text-align:right;white-space:pre;font:13px/1.65 ui-monospace,SFMono-Regular,Consolas,monospace}
.sql-editor .sql-copy-icon{position:absolute;top:7px;right:9px;z-index:3;display:flex;align-items:center;justify-content:center;width:30px;height:30px;padding:0;border:1px solid #d7deea;background:#fff;color:#68758d;border-radius:5px}
.sql-copy-icon:hover{color:#315bd6;background:#edf2ff}
.sql-view>pre.sql-code{margin:0;border:0;border-radius:0;white-space:pre;overflow:auto;max-height:400px;min-height:54px;tab-size:4;font:13px/1.65 ui-monospace,SFMono-Regular,Consolas,monospace}
.template-summary>.sql-compact:not(.workspace-expanded){width:360px;max-width:100%}.sql-compact>pre.sql-code{max-height:80px}
.expand-view-icon{display:flex;align-items:center;justify-content:center;width:30px;height:30px;padding:0;border:1px solid #d7deea;border-radius:5px;background:white;color:#68758d;flex-shrink:0}
.expand-view-icon:hover{color:#315bd6;background:#edf2ff}
.sql-editor>.expand-view-icon{position:absolute;top:7px;right:45px;z-index:3}
.sql-editor .sql-highlight,.sql-editor textarea[data-sql-editor],.sql-view>pre.sql-code{padding-right:88px}
.workspace-expanded:popover-open{position:fixed;inset:0;margin:0;width:100vw;max-width:none;height:100vh;height:100dvh;max-height:none;box-sizing:border-box;border:0;border-radius:0;background:#f8fafc;color:#202b3e}
.sql-editor.workspace-expanded textarea[data-sql-editor],.sql-view.workspace-expanded>pre.sql-code{height:100%;max-height:none;resize:none}
[data-grid-surface].workspace-expanded{padding:16px;display:flex;flex-direction:column;overflow:hidden}
[data-grid-surface].workspace-expanded>.question-sheet{flex:1;min-height:0;max-height:none}
[data-grid-surface].workspace-expanded>.grid-footer{flex-shrink:0}
.grid-row-menu[popover]{inset:auto;margin:0}

/* Multi-value template filters. */
.template-multiselect{position:relative;width:180px;max-width:100%;color:#34425b}
.template-multiselect [data-template-filter-toggle]{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;min-width:0;cursor:pointer;background:#fff;border:1px solid #d7deea;border-radius:6px;padding:8px;text-align:left}
.template-multiselect [data-template-filter-toggle]>span:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.template-multiselect [data-template-filter-toggle]>span:last-child{color:#758298}
.template-multiselect [data-template-filter-toggle]:focus-visible{outline:2px solid #a2b7fa;outline-offset:1px}
.template-filter-options{position:absolute;top:calc(100% + 5px);left:0;min-width:100%;width:max-content;max-width:min(360px,85vw);overflow:hidden;background:#fff;border:1px solid #d7deea;border-radius:7px;box-shadow:0 8px 24px #24365226;padding:5px;z-index:30}
.template-filter-list{max-height:240px;overflow:auto}
.template-filter-all{border-bottom:1px solid #e9edf4;border-radius:0!important;margin-bottom:4px;min-width:0;flex-wrap:wrap}
.template-filter-count{margin-left:auto;white-space:nowrap;flex-shrink:0}
.template-filter-options label{display:flex;align-items:center;gap:8px;padding:8px;border-radius:5px;cursor:pointer;overflow-wrap:anywhere}
.template-filter-options label:hover,.template-filter-options label:focus-within{background:#edf2ff}
.template-filter-options label:has(input:checked){background:#edf2ff;color:#315bd6}
.template-filters .template-filter-options input{width:16px;height:16px;flex:none;margin:0;accent-color:#315bd6}

.sql-view>pre.sql-code{width:100%;min-width:0;box-sizing:border-box}
.sql-editor.workspace-expanded:popover-open{padding:0}

.template-filter-options[hidden]{display:none!important}

.table-empty-row>td{white-space:normal;text-align:center}
.table-empty{padding:44px 16px;color:#758298}
.table-empty strong{font-size:14px;font-weight:500;color:#53627a}
.table-empty p{margin:8px 0 0;font-size:13px}

.template-table tbody tr:nth-child(odd)>td{background:#fff}
.template-table tbody tr:nth-child(even)>td{background:#f7f9fd}
.template-table tbody tr:hover>td{background:#e4edf9}
.template-table .template-index{width:60px;min-width:60px;text-align:center;color:#64748b;font-variant-numeric:tabular-nums}
.template-table .template-time{white-space:nowrap;font-variant-numeric:tabular-nums;color:#526176}

/* Keep SQL gutters and controls below the sticky table header while scrolling. */
.template-table th{z-index:5}
.template-summary>.sql-editor:not(.workspace-expanded){isolation:isolate}

/* The corner belongs to both the fixed header and the fixed row-number column. */
.question-sheet thead th:first-child{left:0;z-index:7}

.preview-sql-heading{display:flex;align-items:baseline;flex-wrap:wrap;gap:8px 14px}
.preview-template-name{font-size:14px;font-weight:400;color:#64748b;overflow-wrap:anywhere;min-width:0}

.export-sql-text{white-space:pre-wrap;overflow-wrap:anywhere}

.question-sheet .grid-preview-cell{user-select:text;background:#f8faff;white-space:normal;vertical-align:middle}
.grid-preview-text{position:absolute;inset:10px;align-content:safe center;white-space:pre-wrap;overflow-wrap:anywhere;overflow:auto;line-height:1.6}
[data-preview-column="sql"] .grid-preview-text{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:13px}
.preview-toggle{display:inline-flex;align-items:center;gap:8px;background:transparent;border-color:transparent;padding:8px 4px;color:inherit}
.preview-toggle:focus-visible{outline:2px solid #315bd6;outline-offset:3px}
.preview-toggle-track{display:inline-flex;align-items:center;width:36px;height:22px;padding:3px;border-radius:999px;background:#8995a7;transition:background .15s}
.preview-toggle-thumb{display:block;width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 3px #0002;transition:transform .15s}
.preview-toggle[aria-checked="true"] .preview-toggle-track{background:#315bd6}
.preview-toggle[aria-checked="true"] .preview-toggle-thumb{transform:translateX(14px)}
@media(prefers-reduced-motion:reduce){.preview-toggle-track,.preview-toggle-thumb{transition:none}}

.question-sheet>table{zoom:var(--grid-zoom,1)}
.question-sheet table [popover]{zoom:calc(1 / var(--grid-zoom,1))}
.grid-zoom-controls{display:flex;align-items:center;gap:6px;order:1}
.grid-zoom-controls button{padding:4px 8px;min-width:30px;height:30px;font-size:13px}
.grid-zoom-controls output{min-width:45px;text-align:center;font-size:13px;font-variant-numeric:tabular-nums;color:#68758d}

/* Compact, distinct authoring and preview surfaces. */
.question-sheet thead th{background:#dce5f2;color:#263b59;font-weight:650;text-align:center;vertical-align:middle;padding:10px 8px;border-color:#c3d0e2}
.question-sheet [data-grid-row]{text-align:center;color:#526580;background:#eef2f7;padding-left:4px;padding-right:4px}
.question-sheet [data-grid-all]{border:0;background:transparent;padding:3px 0;font-size:12px;font-weight:600;color:#263b59}
.question-sheet [data-grid-all].grid-all-selected{color:#174ec2;background:#c4d7ff}
.question-sheet td[data-cell]{background:#fff}
.question-sheet td.grid-unused{background:#e5e7eb;color:#707988}
.question-sheet .grid-preview-cell{background:#e6efff}
.question-sheet td{--range-top:0px;--range-bottom:0px;--range-left:0px;--range-right:0px}
.question-sheet td.grid-selected,.question-sheet td.grid-selected:focus{
  background:#dbe8ff;
  box-shadow:inset 0 var(--range-top) #688cdd,inset 0 var(--range-bottom) #688cdd,inset var(--range-left) 0 #688cdd,inset var(--range-right) 0 #688cdd;
}
.question-sheet td.grid-range-top{--range-top:2px}
.question-sheet td.grid-range-bottom{--range-bottom:-2px}
.question-sheet td.grid-range-left{--range-left:2px}
.question-sheet td.grid-range-right{--range-right:-2px}
.question-sheet td.grid-unused.grid-selected{background:#d0d9e8}
[data-grid-surface].workspace-expanded{padding:0;gap:0}
[data-grid-surface].workspace-expanded>.question-sheet{width:100%;border-radius:0;max-height:none;margin:0}
[data-grid-surface].workspace-expanded>.question-sheet>table{min-width:100%}
[data-grid-surface].workspace-expanded>.grid-footer{margin:0;padding:8px 12px;background:#f5f7fb;border-top:1px solid #d7deea}

/* Outline each contiguous selection once, including preview and status cells. */
.question-sheet tbody tr[aria-selected="true"]{
  --selection-top:2px;
  --selection-bottom:-2px;
}
.question-sheet tbody tr[aria-selected="true"]+tr[aria-selected="true"]{
  --selection-top:0px;
}
.question-sheet tbody tr[aria-selected="true"]:has(+tr[aria-selected="true"]){
  --selection-bottom:0px;
}
.question-sheet tbody tr[aria-selected="true"]>th[data-grid-row],
.question-sheet tbody tr[aria-selected="true"]>td.grid-selected,
.question-sheet tbody tr[aria-selected="true"]>td{
  background:#dbe8ff;
  box-shadow:inset 0 var(--selection-top) #688cdd,inset 0 var(--selection-bottom) #688cdd;
}
.question-sheet tbody tr[aria-selected="true"]>th:first-child{
  box-shadow:inset 2px 0 #688cdd,inset 0 var(--selection-top) #688cdd,inset 0 var(--selection-bottom) #688cdd;
}
.question-sheet tbody tr[aria-selected="true"]>td:last-child{
  box-shadow:inset -2px 0 #688cdd,inset 0 var(--selection-top) #688cdd,inset 0 var(--selection-bottom) #688cdd;
}
.question-sheet [data-grid-row]:focus{outline:none}

.grid-filter-button{position:absolute;right:7px;bottom:4px;display:grid;place-items:center;width:22px;height:22px;padding:3px;margin:0;background:#fff;color:#60728e;border:1px solid #d7deea;border-radius:4px}.grid-filter-button svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round}.grid-filter-button svg .grid-filter-funnel{fill:currentColor;stroke:none}.grid-filter-button.active{color:#315bd6;background:#fff;border-color:#315bd6}.question-sheet thead th:has(.grid-filter-button){padding-left:34px;padding-right:34px}.grid-dropdown-button{position:absolute;right:8px;top:50%;transform:translateY(-50%);display:grid;place-items:center;width:24px;height:28px;padding:4px;background:transparent;border:1px solid transparent;border-radius:4px;color:#7d8795}.grid-dropdown-button svg{width:16px;height:16px;fill:currentColor}.grid-dropdown-button:hover{background:#fff;border-color:#b8c8e4;color:#315bd6}.grid-dropdown-button:focus-visible,.grid-filter-button:focus-visible{outline:2px solid #315bd6;outline-offset:1px}.question-sheet td:has(>.grid-dropdown-button)>.grid-cell-text{right:38px}.column-filter-panel{position:fixed;inset:auto;margin:0;width:360px;max-width:calc(100vw - 16px);max-height:calc(100vh - 16px);overflow:auto;padding:16px;background:#fff;color:#202b3e;border:1px solid #d7deea;border-radius:12px;box-shadow:0 10px 32px #20385826;font:13px Inter,-apple-system,BlinkMacSystemFont,"Microsoft YaHei",sans-serif;z-index:1000}.column-filter-panel [hidden]{display:none!important}.column-filter-panel .muted{font-size:12px}.filter-heading,.filter-sort,.filter-tabs,.filter-actions{display:flex;align-items:center;gap:10px}.filter-heading{justify-content:space-between;margin-bottom:12px}.filter-heading button{border:0;padding:2px 8px}.filter-sort button,.filter-tabs button{flex:1}.filter-tabs{margin:14px 0;border-bottom:1px solid #d7deea}.filter-tabs button{border:0;border-radius:0}.column-filter-panel button[aria-pressed=true]{color:#315bd6;background:#eef2ff;font-weight:600}.filter-tabs button[aria-pressed=true]{border-bottom:2px solid #315bd6}.column-filter-panel [data-search]{width:100%;margin-bottom:10px}.filter-options{max-height:260px;overflow:auto}.filter-option{display:flex;align-items:center;gap:10px;padding:9px 0;cursor:pointer;overflow-wrap:anywhere}.filter-option input{flex:none;width:17px;height:17px;accent-color:#315bd6}.filter-option span:last-child{margin-left:auto;color:#758298;flex:none}.filter-option span:nth-child(2):not(:last-child){flex:1}.filter-actions{padding-top:12px;border-top:1px solid #d7deea}.filter-actions .link{margin-right:auto}.column-filter-panel [data-condition]{display:grid;gap:12px;min-height:160px}.column-filter-panel [data-condition] label{display:grid;gap:8px}

.question-sheet .grid-actions{white-space:normal}.grid-actions .actions{margin:0;gap:6px}.grid-actions button{font-size:12px;padding:3px 6px}

.column-row[data-export-unavailable]{opacity:.5;cursor:not-allowed}.column-row[data-export-unavailable]>*{pointer-events:none}

.column-row[data-export-required]>input[type="checkbox"]{pointer-events:none}

.column-row>span{min-width:0;overflow-wrap:anywhere}.column-row>input[data-label]{min-width:0;width:100%;box-sizing:border-box}

.export-profile-picker{display:flex;align-items:center;gap:8px;max-width:100%}.export-profile-picker .editable-select{width:300px;min-width:0}.export-profile-picker>select{width:300px}

.template-filters .template-filter-options [data-template-option-search]{width:100%;height:auto;margin:0 0 5px;padding:8px;box-sizing:border-box}
.template-filter-options label[hidden]{display:none}

.template-name-search{position:relative;width:180px;max-width:100%}
.template-filters .template-name-search input{width:100%;box-sizing:border-box;padding-right:32px}
.template-name-search [data-template-name-clear]{position:absolute;right:5px;top:50%;transform:translateY(-50%);display:flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:0;border-radius:50%;background:transparent;color:#758298;font-size:20px;cursor:pointer}
.template-name-search [data-template-name-clear]:hover{background:#edf2ff;color:#315bd6}
.template-name-search [data-template-name-clear][hidden]{display:none}

/* Compact SQL template list; expanded SQL and drawers retain their reading size. */
#body:has(:is(.template-table,.metric-table,.parameter-table)){font-size:12px}
.template-toolbar,.template-filters{gap:8px;margin-bottom:10px}
.template-batch-actions{display:flex;align-items:center;flex-wrap:wrap;gap:6px;margin-left:auto}
.template-toolbar button,.template-filters button,.template-filters input{font-size:12px;line-height:18px;padding:5px 9px}
.template-toolbar :is(#addMetric,#createSourceMetrics,#addParameter,#createSourceParameters){box-sizing:border-box;height:30px;display:inline-flex;align-items:center;justify-content:center}
.template-filters .template-multiselect [data-template-filter-toggle]{padding:5px 8px}
.template-filters .muted,.template-table .muted{font-size:11px}
.template-filters .template-multiselect,.template-filters .template-name-search{width:160px}
.template-table td,.template-table th{padding:8px}
.template-table .template-index{width:40px;min-width:40px}
.template-table .template-summary{min-width:220px;max-width:300px}
.template-table .detail-name{font-size:12px}
.template-table .template-summary>p{margin:3px 0 6px;line-height:16px}
.template-table .template-metrics{min-width:100px;max-width:180px}
.template-table .tag,.template-table .metric-badge{font-size:11px;padding:3px 5px}
.template-table .actions{flex-wrap:nowrap;gap:4px}
.template-table .actions>button{font-size:12px;line-height:18px;padding:4px 7px}
.template-table .actions>.template-more{font-size:18px;width:28px;padding:4px 0}
.template-summary>.sql-compact:not(.workspace-expanded){width:280px}
.template-summary>.sql-compact:not(.workspace-expanded)>pre.sql-code{font-size:11px;line-height:16px;min-height:48px;max-height:48px;padding:7px 64px 7px 38px}
.template-summary>.sql-compact:not(.workspace-expanded) .sql-line-numbers{width:30px}
.template-summary>.sql-compact:not(.workspace-expanded) .sql-line-numbers>div{font-size:11px;line-height:16px;padding:7px 6px}
.template-summary>.sql-compact:not(.workspace-expanded)>button{width:22px;height:22px;top:4px;padding:3px}
.template-summary>.sql-compact:not(.workspace-expanded)>button svg{width:14px;height:14px}
.template-summary>.sql-compact:not(.workspace-expanded)>.sql-copy-icon{right:4px}
.template-summary>.sql-compact:not(.workspace-expanded)>.expand-view-icon{right:30px}
.template-action-menu{position:fixed;inset:auto;margin:0;min-width:112px;padding:4px;border:1px solid #dfe5ef;border-radius:7px;background:#fff;box-shadow:0 8px 24px #233c7220}
.template-action-menu:popover-open{display:grid;gap:2px}
.template-action-menu button{font-size:12px;text-align:left;border:0;padding:6px 10px}

/* Let the template list use the viewport remaining below its compact controls. */
#workspace:has(:is(.template-table,.metric-table,.parameter-table,#questionGrid)){height:100vh;height:100dvh;min-height:360px;padding:6px 14px;display:flex;flex-direction:column}
#workspace>header{height:40px;flex:none;padding-bottom:6px;margin-bottom:4px}
#workspace:has(:is(.template-table,.metric-table,.parameter-table,#questionGrid))>#editor{display:flex;flex-direction:column;flex:1;min-height:0}
#workspace .tabs{flex:none;margin:0 0 8px}
#workspace .tabs button{padding:6px 2px;font-size:var(--toolbox-text)}
#body:has(:is(.template-table,.metric-table,.parameter-table)){display:flex;flex-direction:column;flex:1;min-height:0}
#body:has(:is(.template-table,.metric-table,.parameter-table))>.toolbar{flex:none}
#body:has(:is(.template-table,.metric-table,.parameter-table))>.table-wrap{flex:1;min-height:0;max-height:none}
#body:has(:is(.template-table,.metric-table,.parameter-table))>.list-pagination{flex:none;margin:6px 0 0}
.template-table thead th,.template-table thead th.template-index{text-align:left}

.template-title-line{display:flex;align-items:center;gap:8px;min-height:24px}
.template-title-line>.detail-name{min-width:0;overflow-wrap:anywhere}
.template-sql-shortcuts{display:inline-flex;flex:none;gap:2px}
.template-sql-shortcuts button{display:flex;align-items:center;justify-content:center;width:24px;height:24px;padding:4px;border:0;background:transparent;color:#758298;border-radius:4px}
.template-sql-shortcuts button:hover{background:#eaf0ff;color:#315bd6}
.template-sql-shortcuts svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.template-table .template-summary>p{margin:2px 0 0}

/* Shared typography across toolbox tabs and all right-hand drawers. */
:root{--toolbox-text:12px;--toolbox-caption:11px;--toolbox-heading:14px;--drawer-text:13px;--drawer-caption:12px;--drawer-title:16px}
#workspace{font-size:var(--toolbox-text)}
#body{font-size:var(--toolbox-text)}
#workspace :is(.detail-name,.preview-template-name,.question-sheet thead th,.question-sheet tbody th,.grid-preview-text,.list-pagination,.set-picker,.form,.help,.error){font-size:var(--toolbox-text)}
#workspace :is(.toolbar,.question-toolbar,.question-filters,.actions,.list-pagination,.form) :is(button,input,select,textarea),#workspace .menu-items button{font-size:var(--toolbox-text)}
#workspace :is(.muted,.tag,.metric-badge,small){font-size:var(--toolbox-caption)}
#workspace :is(h2,h3){font-size:var(--toolbox-heading)}
#workspace :is(.toolbar,.question-toolbar) > button,#workspace .question-primary-actions>button{padding:5px 9px;line-height:18px}
#workspace .template-more{font-size:18px}
#workspace .list-pagination .page-arrow{font-size:25px}
#workspace .template-name-search [data-template-name-clear]{font-size:20px}
#workspace .grid-append-rows button{font-size:24px}
#workspace .workspace-breadcrumb h1{font-size:16px;margin:0;line-height:24px}
#workspace .workspace-breadcrumb>.link,#workspace .project-combo>input,#workspace .workspace-header-actions #save{font-size:var(--toolbox-text)}
.right-drawer{font-size:var(--drawer-text);line-height:1.6}
.right-drawer :is(button,input,select,textarea,label,table,.detail-name,.preview-template-name,.help,.form,.detail-grid){font-size:var(--drawer-text)}
.right-drawer :is(.muted,small,.tag,.metric-badge,.error,.select-search-hint,.template-reference-rows .link){font-size:var(--drawer-caption)}
.right-drawer :is(h2,h3){font-size:var(--toolbox-heading);line-height:1.5}
.right-drawer .dialog-head h2{font-size:var(--drawer-title)}
.right-drawer :is(.sql-highlight,textarea[data-sql-editor],pre.sql-code,.sql-line-numbers>div){font-size:var(--drawer-text)}
.template-meta-line{display:flex;align-items:center;gap:8px;min-height:24px;margin-top:2px}
.template-meta-line .muted{white-space:nowrap}

/* Allocate list width to content; metadata uses predictable compact columns. */
:is(.template-table,.metric-table,.parameter-table){table-layout:fixed;min-width:960px}
:is(.template-table,.metric-table,.parameter-table) th{text-align:left}
:is(.template-table,.metric-table,.parameter-table) td,:is(.template-table,.metric-table,.parameter-table) th{padding:8px;white-space:normal;overflow-wrap:anywhere}
:is(.template-table,.metric-table,.parameter-table) .template-index{width:36px;min-width:0;text-align:center;color:#64748b}
:is(.template-table,.metric-table,.parameter-table) th.template-index{text-align:left}
.template-table .template-summary,.template-table .template-metrics{min-width:0;max-width:none}
:is(.template-table,.metric-table,.parameter-table) .template-time{white-space:normal;font-size:11px;color:#64748b;font-variant-numeric:tabular-nums}
.list-date,.list-clock{display:block;white-space:nowrap;line-height:17px}
.list-clock{color:#8792a5}
.metric-table tbody tr:nth-child(odd)>td{background:#fff}
.metric-table tbody tr:nth-child(even)>td{background:#f7f9fd}
.metric-table tbody tr:hover>td{background:#e4edf9}
.metric-table .actions{flex-wrap:nowrap;gap:4px}
.metric-table .actions>button{font-size:12px;line-height:18px;padding:4px 7px}
.metric-table .actions>.template-more{font-size:18px;width:28px;padding:4px 0}
:is(.template-table,.metric-table,.parameter-table) .metric-badge{max-width:100%;white-space:normal;overflow-wrap:anywhere}
.metric-filters{gap:8px;margin-bottom:10px}
.metric-filters input{font-size:12px;padding:5px 9px;line-height:18px;width:160px}
.metric-filters #metricSearch{width:220px}

:is(.template-table,.metric-table,.parameter-table) .actions>button{flex-shrink:0}
.metric-table .metric-description{min-width:0;max-width:none}
.metric-description>span{display:-webkit-box;max-width:10em;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;overflow-wrap:anywhere}

/* Compact shared drawer chrome and SQL detail metadata. */
.right-drawer .dialog-head{padding:10px 20px;min-height:48px}
.right-drawer .dialog-head>button{width:28px;height:28px;padding:0}
.right-drawer #modalBody{padding:16px 20px}
.right-drawer #modalActions{padding:10px 20px}
.template-detail-title{display:flex;align-items:center;flex-wrap:wrap;gap:6px;margin-bottom:10px}
.template-detail-title h2{margin:0;flex:1;min-width:180px}
.template-detail-summary{grid-template-columns:82px minmax(0,1fr) 48px minmax(0,1fr);gap:6px 10px;margin:0}
.template-detail-summary .detail-wide{grid-column:2 / -1}
.template-detail-summary .metric-badge,.template-detail-summary .tag{padding:2px 5px;margin:1px}
.template-detail-extra{margin:10px 0;color:#64748b;font-size:12px}
.template-detail-extra summary{cursor:pointer;padding:4px 0}
.template-detail-extra .detail-grid{gap:6px 10px;margin:8px 0}
.template-detail-extra .template-reference{display:flex;align-items:baseline;flex-wrap:wrap;gap:6px;margin-bottom:4px}
.template-detail-extra .template-reference-rows{margin:0}
.right-drawer :is(.sql-highlight,textarea[data-sql-editor],pre.sql-code,.sql-line-numbers>div){font-size:12px;line-height:1.6}
.sql-copy-feedback{position:absolute;top:9px;right:86px;z-index:4;padding:3px 8px;border:1px solid #cde6d7;border-radius:5px;background:#f1fbf5;color:#24824b;font:12px/18px sans-serif;pointer-events:none}
.sql-copy-feedback[hidden]{display:none}
.sql-copy-feedback.error{color:#ba3548;background:#fff5f5;border-color:#f0c7cc}
@media(max-width:540px){.template-detail-summary{grid-template-columns:82px minmax(0,1fr)}.template-detail-summary .detail-wide{grid-column:2}}

.template-metric-tags{display:flex;flex-wrap:wrap;align-content:flex-start;align-items:flex-start;gap:4px;max-height:48px;overflow:hidden}
.template-table .template-metric-tags .metric-badge{flex:none;max-width:100%;margin:0;padding:3px 5px;line-height:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.metrics-expanded>.template-metric-tags{max-height:none}
.template-metrics-toggle{display:block;margin-top:4px;font-size:11px;line-height:18px}
.template-metrics-toggle[hidden]{display:none}

/* SQL owns the remaining drawer height; long code scrolls within its pane. */
.right-drawer #modalBody:has(>.template-preview-layout),.right-drawer #modalBody:has(>.template-edit-layout){display:flex;overflow:hidden;padding-bottom:10px}
.template-preview-layout,.template-edit-layout{display:flex;flex-direction:column;flex:1;min-width:0;min-height:0;gap:8px}
.template-preview-meta{flex:0 1 auto;max-height:45%;min-height:0;overflow:auto}
.template-preview-layout>.sql-section-heading{flex:none;margin:0}
.template-preview-layout>.sql-section-heading h3{margin:0}
.template-preview-layout>.sql-view:not(.workspace-expanded){flex:1;min-height:0}
.template-preview-layout>.sql-view:not(.workspace-expanded)>pre.sql-code{height:100%;max-height:none;min-height:0}
.template-edit-meta{flex:0 1 auto;max-height:50%;min-height:0;overflow:auto;padding:2px}
.template-edit-meta .help,.template-edit-meta p{margin:0}
.template-edit-sql{display:flex;flex-direction:column;flex:1;min-height:0}
.template-edit-sql>.sql-section-heading{flex:none}
.template-edit-sql>.sql-editor:not(.workspace-expanded){flex:1;min-height:0}
.template-edit-sql>.sql-editor:not(.workspace-expanded)>textarea[data-sql-editor]{height:100%;min-height:0;max-height:none;resize:none}
.template-edit-layout>#templateDeps{flex:none;max-height:48px;overflow:auto}

/* Compact template metadata leaves most of the drawer for writing SQL. */
.template-edit-meta.form{flex:none;max-height:none;overflow:visible;gap:8px;padding:0}
.template-edit-fields{display:grid;grid-template-columns:1fr 1fr;gap:10px 20px}
.template-edit-fields>label:first-child{grid-column:1 / -1}
.template-edit-fields>label{display:grid;grid-template-columns:64px minmax(0,1fr);align-items:center;min-width:0;gap:8px}
.template-edit-fields>label>span{color:#64748b;white-space:nowrap}
.template-edit-fields>label input,.template-edit-fields select{width:100%;min-width:0}
.template-edit-fields .choice-only>input{cursor:pointer;padding-right:32px;background:#fff;color:#34425b;border-color:#d7deea}
.right-drawer .select-clear{position:absolute;right:4px;top:50%;transform:translateY(-50%);display:flex;align-items:center;justify-content:center;width:22px;height:22px;min-height:0;padding:0;border:0;border-radius:50%;background:transparent;color:#94a3b8}
.right-drawer .select-clear[hidden]{display:none}
.right-drawer .select-clear:hover{background:#edf2f7;color:#475569}
.select-clear svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round}
.template-edit-fields label>small.error{grid-column:2}
.template-edit-fields label>small.error:empty{display:none}
.template-edit-fields>label input,.template-edit-fields select{height:30px;padding:4px 8px}
.template-edit-fields>.template-table-field{grid-column:1 / -1}
.template-edit-fields>.template-table-field textarea{width:100%;min-width:0;height:30px;min-height:30px;max-height:96px;padding:4px 8px;resize:vertical;font-size:12px}
.template-edit-meta .metric-picker{gap:4px}
.template-edit-meta .metric-picker-control>input{height:38px;padding:7px 30px 7px 8px}
.template-edit-meta .metric-picker-control>span{top:50%;transform:translateY(-50%)}
#templateMetricLabel{align-self:center}
.template-edit-meta .metric-selected{max-height:48px;overflow:auto;gap:4px}
.template-edit-meta .metric-selected .metric-badge{padding:2px 5px}
.template-edit-meta #templateMetricError:empty{display:none}
.template-status-note{line-height:18px}
.template-edit-sql>.sql-section-heading{margin:2px 0 8px;gap:6px;align-items:center}
.template-edit-sql>.sql-section-heading>label{display:block}
.right-drawer .sql-help-button{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;padding:0;border-radius:50%;font-size:11px;color:#68758d}
.sql-input-hint{margin-left:auto}
.sql-help-popover{position:fixed;inset:0;margin:auto;width:min(440px,calc(100vw - 32px));height:fit-content;max-height:70vh;overflow:auto;padding:16px;border:1px solid #d7deea;border-radius:8px;background:#fff;color:#34425b;box-shadow:0 8px 30px #233c7226;font-size:13px;line-height:1.6}
.sql-help-popover p{margin:8px 0 0}
@media(max-width:540px){.template-edit-fields{grid-template-columns:1fr;gap:8px}.sql-input-hint{display:none}}

.required-label::before{content:'*';color:#d93045;margin-right:3px}
.template-edit-fields>label{grid-template-columns:86px minmax(0,1fr)}
.template-edit-meta #templateMetricPicker{display:grid;grid-template-columns:86px minmax(0,1fr);align-items:start;gap:8px}
#templateMetricLabel,.selected-metric-label{color:#64748b;line-height:30px;white-space:nowrap}
.template-edit-meta #templateMetricSelected{max-height:72px;align-items:center;min-height:30px}
#templateMetricError{grid-column:2}
.free-choice{display:block;position:relative;min-width:0}
.free-choice>input{display:block;width:100%;padding-right:32px}
.right-drawer .free-choice-toggle{position:absolute;right:2px;top:50%;transform:translateY(-50%);width:26px;height:26px;padding:0;border:0;background:transparent;color:#758298}
.free-choice-options{position:fixed;inset:auto;margin:0;padding:4px;border:1px solid #d7deea;border-radius:6px;background:#fff;box-shadow:0 6px 20px #233c7220;overflow:auto;color:#34425b;font-size:13px}
.free-choice-options>[role=option],.free-choice-options>.muted{padding:6px 8px;overflow-wrap:anywhere}
.free-choice-options>[role=option]{cursor:pointer;border-radius:4px}
.free-choice-options>[role=option]:hover,.free-choice-options>[aria-selected=true]{background:#edf2ff;color:#315bd6}

/* Keep the collapsed metric cell, including its action, within two rows. */
[data-collapsible-metrics]{position:relative}
[data-collapsible-metrics]:not(.metrics-expanded)>.template-metric-tags{padding-right:32px}
[data-collapsible-metrics]:not(.metrics-expanded)>.template-metrics-toggle{position:absolute;right:0;bottom:0;margin:0;line-height:22px}
.project-shortcuts{display:flex;align-items:center;gap:4px;margin-left:-10px;flex:none}
.project-shortcuts button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:5px;border:0;background:transparent;color:#68758d;border-radius:5px}
.project-shortcuts button:hover{background:#eaf0ff;color:#315bd6}
.project-shortcuts svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
#save[hidden]{display:none}

/* The short board label should sit next to its field. */
.template-edit-fields>label:nth-child(3){grid-template-columns:32px minmax(0,1fr)}
.template-edit-meta .selected-metrics-group:not(.metrics-expanded)>#templateMetricSelected{height:48px;min-height:48px;max-height:48px;overflow:hidden;padding-right:0;align-content:flex-start;align-items:flex-start}
.template-edit-meta #templateMetricSelected .metric-badge{height:22px;line-height:16px;padding:3px 5px;margin:0;max-width:100%;white-space:nowrap}
.template-edit-meta #templateMetricSelected .metric-badge button{flex:none;line-height:16px;font-size:14px;padding:0 3px}
.selected-metrics-group:not(.metrics-expanded)>.template-metrics-toggle{position:static;margin-top:4px;line-height:18px}
.template-edit-meta .selected-metrics-group.metrics-expanded>#templateMetricSelected{height:auto;min-height:48px;max-height:none;overflow:visible;padding-right:0;align-items:flex-start}
.template-edit-meta:has(.selected-metrics-group.metrics-expanded){flex:0 1 auto;max-height:55%;overflow:auto}
@media(max-width:540px){.template-edit-fields>label:nth-child(3){grid-template-columns:86px minmax(0,1fr)}}

.template-edit-meta #templateMetricSelected>.muted{line-height:30px}

/* Give list content the height previously consumed by pagination padding. */
#body:has(:is(.template-table,.metric-table,.parameter-table))>.list-pagination{padding:0;margin:6px 0 0;gap:8px;min-height:30px}
#body:has(:is(.template-table,.metric-table,.parameter-table))>.list-pagination :is(button,.page-jump input,.editable-select>input){height:28px;min-height:28px;padding-top:3px;padding-bottom:3px}
#body:has(:is(.template-table,.metric-table,.parameter-table))>.list-pagination .page-numbers{gap:4px}

.parameter-table{min-width:1100px}
.parameter-table tbody tr:nth-child(odd)>td{background:#fff}
.parameter-table tbody tr:nth-child(even)>td{background:#f7f9fd}
.parameter-table tbody tr:hover>td{background:#e4edf9}
.parameter-table .actions{flex-wrap:nowrap;gap:4px}
.parameter-table .actions>button{font-size:12px;line-height:18px;padding:4px 7px}
.parameter-table code{font-size:12px;overflow-wrap:anywhere}
.parameter-table td{height:48px}

.parameter-usage{margin:16px 0}
.parameter-usage h3,.parameter-options-section h3{display:flex;align-items:center;gap:8px;margin:0 0 10px}
.parameter-usage-groups{display:grid;gap:8px}
.parameter-usage-group{border:1px solid #e1e6ef;border-radius:6px;overflow:hidden}
.parameter-usage-group summary{display:flex;align-items:center;gap:8px;list-style:none;padding:7px 10px;background:#f7f9fc;cursor:pointer}
.parameter-usage-group summary::-webkit-details-marker{display:none}
.parameter-usage-group summary::before{content:'▸';color:#758298}
.parameter-usage-group[open] summary::before{content:'▾'}
.parameter-usage-group .usage-expand-hint{margin-left:auto}
.usage-expand-hint::after{content:'展开'}
.parameter-usage-group[open] .usage-expand-hint::after{content:'收起'}
.parameter-usage-group ol{margin:0;padding:0;list-style:none;counter-reset:usage;max-height:180px;overflow:auto}
.parameter-usage-group li{display:flex;gap:10px;padding:8px 12px;line-height:20px;overflow-wrap:anywhere;border-top:1px solid #eef1f6;counter-increment:usage}
.parameter-usage-group li::before{content:counter(usage);color:#8792a5;min-width:20px;flex:none;font-variant-numeric:tabular-nums}
.parameter-options-table{table-layout:fixed}
.parameter-options-table th,.parameter-options-table td{text-align:left;padding:8px 12px;white-space:normal;overflow-wrap:anywhere}
.parameter-options-table tbody tr:nth-child(even){background:#f7f9fd}
.right-drawer #modalBody:has(>.parameter-detail-meta){display:flex;flex-direction:column;padding-bottom:10px}
.right-drawer #modalBody>.parameter-detail-meta{grid-template-columns:auto minmax(0,2fr) auto minmax(0,1fr) auto minmax(0,1fr);align-items:baseline;column-gap:10px;flex:none}
.right-drawer #modalBody:has(>.parameter-detail-meta)>h2,.right-drawer #modalBody:has(>.parameter-detail-meta)>.parameter-usage{flex:none}
#modalBody:has(>.parameter-detail-meta)>h2{margin-bottom:8px}
#modalBody>.parameter-detail-meta{margin:0}
#modalBody:has(>.parameter-detail-meta)>.parameter-usage{margin:10px 0}
#modalBody:has(>.parameter-detail-meta)>.parameter-usage>p{margin:0}
#modalBody:has(#parameterSourceReviewRows)>.source-toolbar{margin-bottom:6px}
#modalBody:has(#parameterSourceReviewRows)>.source-toolbar+p.muted{margin-top:4px}
.right-drawer #modalBody:has(>.parameter-detail-meta)>.parameter-options-section{display:flex;flex-direction:column;flex:1;min-height:180px}
.right-drawer #modalBody:has(>.parameter-detail-meta) .parameter-options-section>.table-wrap{flex:1;min-height:0;max-height:none;overflow:auto}
.right-drawer #modalBody:has(>.parameter-detail-meta) .parameter-options-section>.list-pagination{flex:none;margin:8px 0 0;padding:4px 0}
@media(max-width:600px){.right-drawer #modalBody>.parameter-detail-meta{grid-template-columns:auto minmax(0,1fr)}}

.parameter-usage-link{display:flex;align-items:baseline;justify-content:space-between;gap:10px;flex:1;min-width:0;text-align:left;white-space:normal;overflow-wrap:anywhere;line-height:20px}
.parameter-usage-link>span{flex:none;color:#8792a5}

.parameter-usage-group li:has(.parameter-usage-rows){display:grid;grid-template-columns:20px minmax(0,1fr)}
.parameter-usage-rows{grid-column:2;display:flex;flex-wrap:wrap;gap:6px 12px}
.parameter-usage-rows button{font-size:12px}
.template-table tbody tr.reference-target>td{background:#eaf1ff;box-shadow:inset 0 1px #8cacf0,inset 0 -1px #8cacf0}

/* Question sheet and list tabs share the same bottom action baseline. */
#body:has(>#questionGrid){display:flex;flex-direction:column;flex:1;min-height:0}
#body:has(>#questionGrid)>.toolbar{flex:none}
#questionGrid:not(.workspace-expanded){display:flex;flex-direction:column;flex:1;min-height:0}
#questionGrid:not(.workspace-expanded)>.question-sheet{flex:1;min-height:0;max-height:none;width:100%}
#questionGrid:not(.workspace-expanded)>.grid-footer{flex:none;min-height:30px;margin:6px 0 0;gap:8px}
#questionGrid:not(.workspace-expanded)>.grid-footer button{height:28px;min-height:28px;padding-top:3px;padding-bottom:3px}
#questionGrid .grid-append-rows button{line-height:22px}
.batch-selection-count{font-size:12px;color:#64748b;white-space:nowrap;flex:none;margin-right:4px}

#body:has(>#questionGrid)>.question-toolbar{flex:none}
:is(.template-table,.metric-table,.parameter-table) :is(th,td)>input[type=checkbox]{display:block;margin:0}

/* Keep template names and linked metrics wider than supporting columns. */
.template-table{min-width:1430px}
.template-table .template-tables{font-size:11px;color:#526176}
.template-table .template-table-ref+.template-table-ref{margin-top:6px;padding-top:6px;border-top:1px solid #dce4f2}
.template-table .template-table-ref code{padding:0;background:none;font:11px/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:#7a879a;overflow-wrap:anywhere}
.template-table .template-table-scope{white-space:nowrap}
.template-table .template-table-ref code.template-table-name{color:#2f3c52}
.template-table .template-table-dot{color:#7a879a}

/* Reserve readable supporting columns before distributing the remaining space. */
.metric-table{min-width:1600px}
:is(.template-table,.metric-table) th{white-space:nowrap;overflow-wrap:normal}
:is(.template-table,.metric-table) .list-context{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;overflow-wrap:normal}
:is(.template-table,.metric-table) .template-time{white-space:nowrap;overflow-wrap:normal}

.parameter-table th,.parameter-table .template-time{white-space:nowrap;overflow-wrap:normal}

:is(.template-table,.metric-table,.parameter-table) .batch-selectable{cursor:pointer}
:is(.template-table,.metric-table,.parameter-table) .batch-selectable:has(input[type=checkbox]:checked)>td{background:#eaf1ff}
.batch-selectable button:disabled{pointer-events:none}
.batch-selectable:focus-visible{outline:2px solid #8cacf0;outline-offset:-2px}

.question-sheet .grid-month-picker{position:fixed;inset:auto;margin:0;width:280px;min-width:0;max-width:calc(100vw - 16px);padding:12px;border:1px solid #d7deea;border-radius:8px;background:#fff;color:#34425b;box-shadow:0 8px 24px #24365226;overflow:auto;white-space:normal;font:13px/1.5 Inter,-apple-system,BlinkMacSystemFont,"Microsoft YaHei",sans-serif}
.grid-month-picker .month-year-controls{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:10px}
.grid-month-picker .month-year-controls label{display:flex;align-items:center;justify-content:center;gap:4px}
.question-sheet .grid-month-picker input{position:static;width:86px;min-width:0;height:30px;padding:4px 6px;text-align:center;font:inherit}
.grid-month-picker button{padding:5px 8px;font:inherit;min-height:30px}
.grid-month-picker .month-choices{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
.grid-month-picker .month-choices button{border-color:transparent;background:#f6f8fc}
.grid-month-picker .month-choices [data-current-month]{border-color:#a2b7fa}
.grid-month-picker .month-choices [aria-pressed=true]{background:#315bd6;color:#fff;border-color:#315bd6}
.grid-month-picker .month-picker-actions{display:flex;justify-content:space-between;gap:8px;margin-top:10px;padding-top:8px;border-top:1px solid #e9edf4}

/* Compact single-row actions; viewing controls share the existing table footer. */
#workspace .question-toolbar{flex-wrap:nowrap;gap:8px}
#workspace .question-toolbar .set-picker{flex:0 1 auto;min-width:0}
#workspace .question-toolbar .set-picker .editable-select{width:180px;min-width:110px}
#workspace .question-primary-actions{flex-wrap:nowrap;margin-left:auto;gap:6px}
.question-action-divider{width:1px;height:18px;background:#d7deea;margin:0 3px;flex:none}
#questionGrid .question-footer-controls{display:flex;align-items:center;gap:10px;margin:0;white-space:nowrap}
#questionGrid .question-footer-controls .muted{display:grid;font-size:12px;flex:none;font-variant-numeric:tabular-nums}
.question-count-size,.question-count-value{grid-area:1 / 1}
.question-count-size{visibility:hidden;pointer-events:none;user-select:none}
#questionGrid .question-footer-controls button{font-size:12px;padding:4px 6px}
#questionGrid .question-footer-controls [hidden]{display:none!important}
#questionGrid .grid-footer-left{gap:12px;flex-wrap:wrap}
@media(max-width:850px){#workspace .question-toolbar{flex-wrap:wrap}#workspace .question-primary-actions{margin-left:0;flex-wrap:wrap}#questionGrid .question-footer-controls{flex-wrap:wrap}}

#questionGrid #clearQuestionFilters:disabled{color:#98a2b3;opacity:1;cursor:default;background:transparent}

/* Batch fill floats over the sheet and can be moved by its title bar. */
dialog.right-drawer.floating-dialog{inset:auto;left:max(12px,calc(50vw - 220px));top:max(12px,calc(50vh - 190px));top:max(12px,calc(50dvh - 190px));width:min(440px,calc(100vw - 24px));height:auto;max-height:calc(100vh - 24px);max-height:calc(100dvh - 24px);border:1px solid #d7deea;border-radius:12px;box-shadow:0 12px 40px #1d315329}
dialog.floating-dialog::backdrop{background:#17233c14}
.floating-dialog .dialog-head{cursor:grab;touch-action:none;user-select:none}
.floating-dialog .dialog-head.dragging{cursor:grabbing}
.floating-dialog #modalBody .form{gap:10px}
.floating-dialog #modalBody p{margin:0}
.floating-dialog #batchValueControl>input,.floating-dialog #batchValueControl>.editable-select{width:100%}

.floating-dialog .batch-fill-dynamic{color:#315bd6;font-weight:600}

#questionGrid>.question-toolbar{flex:none;position:relative;z-index:8}
#questionGrid.workspace-expanded>.question-toolbar{padding:8px 12px;margin:0;border-bottom:1px solid #d7deea;background:#f8fafc}

/* Match the project shortcuts beside the question-set picker. */
#workspace .set-shortcuts{margin-left:0;gap:4px}
#workspace .set-shortcuts>button,#workspace .set-shortcuts summary{display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:5px;border:0;border-radius:5px;background:transparent;color:#68758d}
#workspace .set-shortcuts>button:hover,#workspace .set-shortcuts summary:hover{background:#eaf0ff;color:#315bd6}
#workspace .set-shortcuts .menu-items button{display:block;width:100%;height:auto;padding:7px 10px;text-align:left;background:transparent;border-radius:5px}
#workspace .set-shortcuts .menu-items .danger{color:#bc3547}
#workspace .set-shortcuts .menu-items button:hover{background:#f1f5ff}

/* Align header contents on one center line without changing their order. */
#workspace>header.workspace-header-inline{align-items:center;padding:3px 0;min-height:40px}
#workspace .workspace-header-inline .workspace-breadcrumb{align-items:center}
#workspace .workspace-header-inline .workspace-breadcrumb>.link{display:inline-flex;align-items:center;height:32px;padding:0 7px;line-height:20px}
#workspace .workspace-header-inline .workspace-breadcrumb h1{margin:0;line-height:24px}
#workspace .workspace-header-inline .project-combo>input{height:32px;line-height:20px;padding-top:5px;padding-bottom:5px}
#workspace .workspace-header-inline .combo-chevron{top:50%;transform:translateY(-50%);line-height:1}
#workspace .workspace-header-actions{align-items:center;gap:10px}
#workspace .workspace-header-actions #save{display:inline-flex;align-items:center;justify-content:center;gap:5px;height:32px;padding:0 12px;line-height:20px}
#workspace .workspace-header-actions #save[hidden]{display:none}
#workspace .workspace-header-actions #save small{line-height:20px}
#workspace .workspace-header-actions #saveState{line-height:20px;min-height:20px}
#workspace .workspace-header-actions .tool-help{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;line-height:1;flex:none}

/* Route visibility takes precedence over workspace flex layouts. */
#home[hidden],#workspace[hidden],#editor[hidden]{display:none!important}

/* Keep the permission tool inside the platform, with its own independent scroll area. */
#permissionWorkspace{display:flex;flex-direction:column;height:100vh;height:100dvh;min-height:240px;max-width:none;padding:6px 14px;gap:8px}
#permissionWorkspace[hidden]{display:none!important}
.permission-workspace-header{flex:none}
#permissionWorkspace>header.workspace-header-inline{align-items:center;padding:3px 0;min-height:40px;margin-bottom:0}
#permissionWorkspace .workspace-breadcrumb h1{font-size:16px;margin:0;line-height:24px}
#permissionWorkspace .workspace-breadcrumb>.link{display:inline-flex;align-items:center;height:32px;padding:0 7px;font-size:var(--toolbox-text);line-height:20px}
#permissionFrame{display:block;flex:1;min-height:0;width:100%;border:1px solid #dfe5ef;border-radius:8px;background:#fff}

/* User manual: scoped to avoid affecting editor drawers. */
.toolbox-guide{line-height:1.8;color:#34425b;overflow-wrap:anywhere}
.toolbox-guide .guide-intro{margin:0 0 16px;color:#68758d}
.toolbox-guide .guide-nav{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:16px;background:#f5f7fb;border:1px solid #e5eaf2;border-radius:10px}
.toolbox-guide .guide-nav button{text-align:left;white-space:normal;background:#fff;color:#315bd6;padding:8px 10px}
.toolbox-guide .guide-section{padding:20px 0;border-bottom:1px solid #e9edf4}
.toolbox-guide .guide-section:last-child{border-bottom:0}
.toolbox-guide .guide-section h3{margin:0 0 12px;color:#243653;scroll-margin-top:16px}
.toolbox-guide p{margin:10px 0}.toolbox-guide ol{padding-left:24px}.toolbox-guide li{margin:8px 0}
.toolbox-guide dl{margin:12px 0}.toolbox-guide dt{font-weight:600;margin-top:14px}.toolbox-guide dd{margin:4px 0 0;color:#526078}
.toolbox-guide code{background:#eef2f8;padding:2px 5px;border-radius:4px;font-size:12px;white-space:pre-wrap;overflow-wrap:anywhere}
.toolbox-guide pre{padding:14px;background:#f5f7fb;border:1px solid #e5eaf2;border-radius:8px;white-space:pre-wrap}
.toolbox-guide pre code{padding:0;background:transparent}.toolbox-guide .guide-tip{padding:12px 14px;background:#eef3ff;border-radius:8px;color:#526b99}
.toolbox-guide :is(button,h3):focus-visible{outline:2px solid #315bd6;outline-offset:3px}
@media(max-width:520px){.toolbox-guide .guide-nav{grid-template-columns:1fr;padding:12px}}
/* Source assistance reuses existing drawers and SQL editor. */
.source-binding{border-top:1px solid var(--border,#e5e7eb);padding-top:12px;margin-top:12px}
.source-binding summary{cursor:pointer;font-weight:500}
.source-binding .form{margin-top:12px}
/* Preserve a usable SQL editor in short drawers. */
.right-drawer #modalBody:has(>.template-edit-layout){overflow-y:auto}
.template-edit-layout{flex-shrink:0}
.template-edit-sql{flex:1 0 220px;min-height:220px}
.source-loading{display:flex;align-items:center;justify-content:center;gap:14px;min-height:180px;padding:24px}
.source-loading-spinner{width:22px;height:22px;flex-shrink:0;border:3px solid #dbe4f0;border-top-color:#2563eb;border-radius:50%;animation:source-loading-spin .8s linear infinite}
@keyframes source-loading-spin{to{transform:rotate(360deg)}}
@media(prefers-reduced-motion:reduce){.source-loading-spinner{animation:none}}
.source-binding>.form{margin-top:12px}

.current-project-card{margin-bottom:16px}

:is(#sourceRows,#parameterSourceRows) input:is([type=radio],[type=checkbox]){width:16px;min-width:16px;height:16px;padding:0;vertical-align:middle}


.source-model-filter{width:320px;max-width:100%;min-width:0;flex:0 1 320px}
.source-model-filter .template-multiselect{width:100%}
.right-drawer .source-toolbar .source-model-filter [data-template-filter-toggle]{height:auto}
.source-model-filter [data-template-filter-toggle]>span:first-child{white-space:normal;overflow-wrap:anywhere}
.source-model-filter .template-filter-options{width:100%;box-sizing:border-box}

.source-toolbar{align-items:center}
.source-measure-filter{width:240px;max-width:100%;min-width:0;flex:0 1 240px}
.source-measure-filter .template-multiselect{width:100%}
.source-measure-filter .template-filter-options{width:100%;box-sizing:border-box}
.source-toolbar .template-filters{margin:0}
.right-drawer .source-toolbar :is([data-template-filter-toggle],#refreshMetricSources,#appendParameterSources){box-sizing:border-box;height:32px;min-height:32px;padding:5px 9px;line-height:20px;display:flex;align-items:center}

.right-drawer .source-metrics-table{width:100%;min-width:1160px;table-layout:fixed}
.right-drawer .source-create-table{min-width:600px}
.right-drawer .source-metrics-table :is(th,td){text-align:left;padding:10px 8px;vertical-align:top;white-space:normal}
.right-drawer .source-metrics-table th{vertical-align:middle;font-size:12px}
.right-drawer :is(#sourceRows,#parameterSourceRows) input:is([data-source-name],[data-source-description],[data-parameter-label]){box-sizing:border-box;width:100%;min-width:0;max-width:none;height:32px;min-height:32px;padding:5px 8px;font-size:12px;line-height:20px}
.right-drawer .source-metrics-table th:first-child{padding-inline:4px;white-space:nowrap}
.right-drawer .source-metrics-table #sourceAll{display:block;margin:0 auto}
.right-drawer :is(#sourceRows,#parameterSourceRows) input:is([type=radio],[type=checkbox]){display:block;margin:8px auto 0}
.source-cell-main{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-height:16px;margin-top:7px;overflow:hidden;overflow-wrap:anywhere;white-space:normal;font-size:12px}
.right-drawer .source-metrics-table:not(.source-create-table) .source-field{display:flex;align-items:center;min-height:32px;font:11px/16px ui-monospace,SFMono-Regular,Consolas,monospace;color:#52627a;white-space:normal;overflow-wrap:anywhere;word-break:break-word;background:transparent;padding:0}
.source-operator{display:inline-block;margin-top:4px;padding:1px 6px;border-radius:4px;background:#eef0ff;color:#6551b8;font-size:12px;font-weight:500;line-height:18px}
.source-description{padding-top:6px;font-size:12px;line-height:20px;color:#64748b;overflow-wrap:anywhere}
#sourceRows .error:empty{display:none}

.metric-source-shortcut{display:block;max-width:100%;white-space:normal;text-align:left;border:0;background:none;padding:0}
.metric-source-shortcut:hover:not(:disabled){background:#edf2ff}
/* Keep metric metadata compact within the drawer. */
.metric-editor{gap:12px;container-type:inline-size}
#metricBasicInfo>summary{display:flex;align-items:center;justify-content:space-between;cursor:pointer;list-style:none;font-weight:600}
#metricBasicInfo>summary::-webkit-details-marker{display:none}
#metricBasicInfo[open]>summary{margin-bottom:10px}
.metric-basic-toggle{color:#315bd6;font-size:12px;font-weight:400}
.metric-basic-toggle::after{content:"展开 ⌄"}
#metricBasicInfo[open] .metric-basic-toggle::after{content:"收起 ⌃"}
.metric-basic-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px 16px;align-items:start}
.metric-basic-fields>label{min-width:0;grid-template-columns:88px minmax(0,1fr);gap:4px 12px;align-items:start}
.metric-basic-fields>label:has(:is(#metricUnit,#metricBoard)){grid-template-columns:max-content minmax(0,1fr)}
.metric-basic-fields>label>span:first-child{padding-top:6px;line-height:20px}
.metric-basic-fields>label>.error{grid-column:2}
.metric-basic-fields .free-choice{min-width:0}
.metric-basic-fields input{width:100%;min-width:0;height:32px;padding-block:4px}
.metric-description-field{grid-column:1/-1}
.metric-description-field textarea{min-height:48px;resize:vertical}
.metric-editor .error:empty{display:none}
@container (max-width:460px){.metric-basic-fields{grid-template-columns:minmax(0,1fr)}}
#metricEditTabs{margin:0 0 4px}
#metricEditTabs [aria-selected=true]{color:#315bd6;border-bottom:3px solid #315bd6;font-weight:600}
#metricEditSource{min-width:0}
#metricEditSource:focus:not(:focus-visible){outline:none}
.source-picker-readonly{display:block;overflow-wrap:anywhere}
.source-picker-readonly+.source-state-badge{display:block;width:fit-content}
.metric-editor:has(.edit-source-empty):has(#metricEditSource:not([hidden])){gap:4px}
#metricEditSource .edit-source-empty{margin:0}
#metricEditSource .edit-source-empty .link{font-size:inherit;vertical-align:baseline}
#metricEditSource .edit-source-empty .link:hover{text-decoration:underline}
#sourcePickerActions:not(:has(button)),#sourcePickerFooter{display:none}
.right-drawer:has(#metricEditSource:not([hidden])) #sourcePickerFooter:not(:empty){display:contents}
.right-drawer:has(#metricEditSource:not([hidden])) #modalActions:has(#sourcePickerFooter:not(:empty))>button{display:none}
.edit-source-heading:not(:empty){margin-bottom:8px}
#metricEditSource .actions{margin:8px 0}
.edit-source-review-actions{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px 16px;margin:12px 0;padding:8px 12px;border-radius:7px;background:#edf2fa}
.edit-source-review-actions>div{margin-left:auto}
#confirmMetricSourceChange,#applyParameterSourceChanges{color:#315bd6;border-color:#879ee5}
.edit-source-overview{position:relative}
.edit-source-overview:has(.edit-source-manage) .edit-source-card{padding-inline-end:112px}
.edit-source-manage{position:absolute;top:5px;right:8px;z-index:2}
.edit-source-manage summary{cursor:pointer;list-style:none;border:1px solid #d7deea;border-radius:6px;background:#fff;padding:4px 8px}
.edit-source-manage summary::-webkit-details-marker{display:none}
.edit-source-manage>div{position:absolute;right:0;display:grid;min-width:112px;margin-top:4px;padding:4px;border:1px solid #d7deea;border-radius:6px;background:#fff;box-shadow:0 4px 12px #1d315329}
.edit-source-manage button{border:0;text-align:left}
.edit-source-manage .danger{color:#bc3547}
.edit-source-review-actions>div{display:flex;align-items:center;flex-wrap:wrap;gap:4px 10px}
#metricEditSource:has(#editPickerHost > .source-toolbar)>.edit-source-review-actions{display:none}
#metricEditSource h3{margin:0 0 8px}
.edit-source-heading{display:flex;align-items:baseline;gap:12px;flex-wrap:wrap}
.edit-source-heading [role=status]{color:#875211;font-size:12px}
.edit-source-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,250px),1fr));gap:8px}
.edit-source-card{padding:10px 12px;border:1px solid #dfe5ef;background:#f8fafd;border-radius:7px;min-width:0}
.edit-source-card strong{display:block;margin-bottom:6px}
.edit-source-card dl{display:flex;flex-wrap:wrap;gap:4px 20px;margin:0;font-size:12px;line-height:20px}
.edit-source-card dl>div{display:flex;align-items:baseline;gap:8px;min-width:0;max-width:100%}
.edit-source-cards:has(>.edit-source-card + .edit-source-card) dl{flex-direction:column}
.edit-source-cards:has(>.edit-source-card + .edit-source-card) dt{min-width:60px}
.edit-source-card dt{flex:none}
.edit-source-card dt{color:#64748b}
.edit-source-card dd{margin:0;overflow-wrap:anywhere}
.edit-source-card code,.edit-source-card .source-operator{font:var(--toolbox-caption)/18px ui-monospace,SFMono-Regular,Consolas,monospace}
.edit-source-card .source-operator{margin:0 0 0 4px}
.metric-source-name{display:flex;align-items:baseline;gap:8px;line-height:20px}
.metric-source-name code,:is(.metric-table,.source-create-table) .source-field,:is(.metric-table,.source-create-table) .source-operator{font:var(--toolbox-caption)/20px ui-monospace,SFMono-Regular,Consolas,monospace}
:is(.metric-table,.source-create-table) .source-field{display:block}
:is(.metric-table,.source-create-table) .source-operator{display:block;width:fit-content;margin:4px 0;padding:1px 7px;line-height:18px}
.metric-source-name code,:is(.metric-table,.source-create-table) .source-field{color:#334155;overflow-wrap:anywhere;background:none;padding:0}
.metric-source-prefix{color:#7b879b}
.metric-source-detail{display:flex;align-items:center;gap:8px;margin:4px 0}
.metric-source-measure{padding:1px 7px;border-radius:4px;background:#edf2ff;color:#375db0;font-size:var(--toolbox-caption);line-height:18px}
.metric-source-scope{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:11px;line-height:18px;color:#64748b;overflow-wrap:anywhere}
.metric-source-scope.metric-source-missing{color:#dc2626}
.source-status-text.is-missing{color:#dc2626}
.source-status-text.is-unlinked{color:#758298}
.source-status-text.is-linked{color:#315bd6}
.source-change-review{margin:12px 0;min-width:0}
.source-change-table{width:100%;table-layout:fixed;border:1px solid #dfe5ef;border-radius:6px}
.source-change-table th,.source-change-table td{padding:8px 10px;white-space:normal;overflow-wrap:anywhere;text-align:left;vertical-align:top}
.source-change-table th{position:static}
.source-change-table th:first-child{width:22%}
.source-change-json{margin-top:10px}
.source-change-json summary{cursor:pointer;color:#68758d}
.source-change-raw{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:10px}
.source-change-raw pre{max-height:280px;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;font-size:12px}

.source-state-toolbar{display:grid;gap:8px;margin:12px 0}
.source-state-tabs{display:flex;gap:5px;flex-wrap:wrap}
.right-drawer .source-state-toolbar button{box-sizing:border-box;height:32px;min-height:32px;padding:0 8px;display:inline-flex;align-items:center;justify-content:center;line-height:20px;white-space:nowrap}
.source-state-tabs button[aria-pressed=true]{background:#edf2ff;border-color:#99b1f7;color:#315bd6}
.source-state-badge{display:inline-block;padding:1px 6px;margin:4px 0;border-radius:4px;font-size:11px;background:#edf2f7;color:#64748b}
.source-state-badge.ready{background:#e7f5ec;color:#247447}
.source-state-badge.updated,.source-state-badge.unconfirmed{background:#fff3d9;color:#946417}
.source-state-badge.invalid,.source-state-badge.missing{background:#fdeced;color:#ae3a49}
#sourceUpdateReview{border:1px solid #d7deea;border-radius:8px;padding:12px;margin:10px 0;max-height:320px;overflow:auto}
#sourceUpdateReview section{padding:10px 0;border-bottom:1px solid #e5eaf2}
#sourceUpdateReview pre{white-space:pre-wrap;overflow-wrap:anywhere;font-size:11px;max-height:140px;overflow:auto}
#sourceUpdateReview input[type=checkbox]{width:16px;height:16px}

:is([data-source-name],[data-source-description]) + .source-state-badge{display:block;width:fit-content;margin:4px 0 0;white-space:nowrap}

.right-drawer #modalBody:has(#metricEditSource:not([hidden]) .source-toolbar),
.metric-editor:has(#metricEditSource:not([hidden]) .source-toolbar),
#metricEditSource:not([hidden]):has(.source-toolbar),
.right-drawer :is(#modalBody, #editPickerHost):has(> .source-toolbar) {
  display: flex;
  flex-direction: column;
}
.right-drawer :is(#modalBody, #editPickerHost):has(> .source-toolbar) > * {
  flex: none;
}
.right-drawer :is(#modalBody, #editPickerHost):has(> .source-toolbar) > .table-wrap {
  flex: 1 0 100px;
  max-height: none;
}
.right-drawer #sourceSelection {
  margin-bottom: 0;
}

.metric-editor:has(#metricEditSource:not([hidden]) .source-toolbar),
#metricEditSource:not([hidden]):has(.source-toolbar),
#editPickerHost:has(> .source-toolbar) {
  flex: 1 0 auto;
}


/* Give the inline source picker usable rows even in short drawer viewports. */
#metricEditSource:has(#editPickerHost > .source-toolbar)>:is(.edit-source-heading,.edit-source-overview,p){display:none}
:is(#editPickerHost,#modalBody):has(> .source-toolbar + p.muted + #sourceStateToolbar)>.source-toolbar{margin-bottom:6px}
:is(#editPickerHost,#modalBody):has(> .source-toolbar + p.muted + #sourceStateToolbar)>p.muted{margin:4px 0;line-height:1.5}
:is(#editPickerHost,#modalBody):has(> .source-toolbar + p.muted + #sourceStateToolbar)>.source-state-toolbar{margin:6px 0}
.right-drawer #editPickerHost:has(> .source-toolbar)>.table-wrap{flex:1 0 240px;min-height:240px}
@media(max-height:700px){
  .right-drawer #modalBody:has(#editPickerHost > .source-toolbar){padding-block:8px}
  .metric-editor:has(#editPickerHost > .source-toolbar){gap:4px}
  .metric-editor:has(#editPickerHost > .source-toolbar) #metricEditTabs button{padding-block:8px}
  #metricEditSource:has(#editPickerHost > .source-toolbar) #sourcePickerActions{margin:4px 0 8px}
  #editPickerHost .source-create-table :is(th,td){padding-block:6px}
}

.sql-insert-panel button.sql-source-table { font-weight: 600; }
.sql-insert-panel button.sql-source-table:not(:first-child) {
  margin-top: 4px;
  border-top: 1px solid #e5eaf2;
}
.sql-insert-panel button.sql-source-child { padding-inline-start: 27px; }

.sql-insert-menu .sql-insert-panel { flex: 1; }
.sql-insert-tabs { cursor: move; touch-action: none; }
.sql-insert-move { margin-inline-start: auto; align-self: center; padding: 0 6px; color: #758298; }
.sql-insert-resize { flex: none; height: 12px; display: grid; place-items: center; cursor: ns-resize; touch-action: none; }
.sql-insert-resize::after { content: ""; width: 32px; height: 3px; border-radius: 2px; background: #bec9d8; }

.selected-model-group { display: flex; flex: 0 0 100%; min-width: 0; flex-wrap: wrap; align-items: center; gap: 4px; }
.selected-model-group > strong { color: #526582; overflow-wrap: anywhere; font-size: var(--toolbox-caption); }

.template-model-filter { display: grid; grid-template-columns: 86px minmax(0,1fr); align-items: center; gap: 8px; color: #64748b; }
.template-model-filter .template-filters { margin: 0; min-width: 0; }
.template-model-filter .template-multiselect { width: 100%; }
.template-model-filter .template-filter-options { color: #34425b; }

/* Match the metric source drawer's 320px model / 240px field controls.
   Style the visible combobox generated by search-select, not its hidden select. */
.right-drawer .editable-select:has(> #parameterSourceTarget){width:320px;max-width:100%;min-width:0}
.right-drawer :is(.editable-select:has(> #parameterSourceTarget)>input,#sourceParameterName,#sourceParameterKey){box-sizing:border-box;height:32px;min-height:32px;padding:5px 9px;font-size:12px;line-height:20px}
.right-drawer .editable-select:has(> #parameterSourceTarget)>input{padding-right:27px}
.right-drawer :is(#sourceParameterName,#sourceParameterKey){width:240px;max-width:100%}
.right-drawer #modalBody:has(#parameterSourceRows)>.form{gap:10px;margin-bottom:12px}
.right-drawer #modalBody:has(#parameterSourceRows)>.form>.two{grid-template-columns:repeat(2,minmax(0,240px));gap:16px}
@media(max-width:600px){.right-drawer #modalBody:has(#parameterSourceRows)>.form>.two{grid-template-columns:minmax(0,1fr)}}
#parameterSourceCount{margin-bottom:0}

/* Keep parameter source filters together within the drawer width. */
.right-drawer .source-toolbar:has(#parameterSourceModelFilter){display:grid;grid-template-columns:minmax(0,1.33fr) minmax(0,1fr) minmax(0,1fr) max-content;gap:8px;align-items:center}
.right-drawer .source-toolbar:has(#parameterSourceModelFilter){margin-bottom:6px}
.right-drawer .source-toolbar:has(#parameterSourceModelFilter)+p.muted{margin-top:4px}
.right-drawer .source-toolbar:has(#parameterSourceModelFilter)>.template-filters{width:auto;min-width:0;max-width:100%}
.right-drawer .source-toolbar:has(#parameterSourceModelFilter) [data-template-filter-toggle]{height:32px;min-width:0;width:100%}
.right-drawer .source-toolbar:has(#parameterSourceModelFilter) [data-template-filter-toggle]>span:first-child{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}

.parameter-field-kind{display:inline-block;white-space:nowrap;padding:2px 8px;border-radius:4px;font-size:12px;line-height:20px}
.parameter-field-kind.measure{background:#edf2ff;color:#375db0}
.parameter-field-kind.dimension{background:#e6f4f1;color:#216e60}

.right-drawer .source-create-table input[data-merge-label]{width:100%;min-width:0;height:32px;padding:5px 8px;font-size:12px;line-height:20px}

.parameter-source-field-detail{display:flex;align-items:center;gap:6px;margin-top:6px;min-width:0}
.parameter-source-field-detail .parameter-field-kind{flex:none}
.parameter-source-field-detail>code{min-width:0;overflow-wrap:anywhere;background:none;padding:0;color:#52627a;font-size:12px}

.parameter-source-reference+.parameter-source-reference{border-top:1px solid #e9edf4;margin-top:8px;padding-top:8px}
.parameter-source-reference-heading{display:flex;align-items:baseline;flex-wrap:wrap;gap:4px 8px;min-width:0}
.parameter-source-reference-heading input{flex:none;width:16px;height:16px;margin:2px 0 0}
.parameter-source-reference-heading .metric-source-name{min-width:0}
.parameter-source-reference:has([data-parameter-update]) .parameter-source-field-detail{margin-left:24px}
.parameter-source-reference-heading .source-state-badge{margin:0}
.parameter-source-reason{overflow-wrap:anywhere}
.parameter-source-reference p{margin:4px 0;overflow-wrap:anywhere}
.parameter-source-changes{margin-top:4px;font-size:12px;overflow-wrap:anywhere}
.parameter-source-changes summary{cursor:pointer;color:#315bd6}
.parameter-source-changes>div{margin-top:6px;white-space:pre-wrap}

.parameter-source-list .parameter-source-reference{padding-right:4px}
.parameter-source-more>summary{cursor:pointer;color:#315bd6;font-size:12px;padding:8px 0;line-height:20px}
.parameter-source-more:not([open]) .source-more-expanded,.parameter-source-more[open] .source-more-collapsed{display:none}
.parameter-source-more>.parameter-source-reference{border-top:1px solid #e9edf4;padding-top:8px}

/* Align the two text lines in each parameter source row. */
.right-drawer .source-metrics-table:has(>#parameterSourceReviewRows)>thead>tr>th{padding-inline:8px}
#parameterSourceReviewRows :is(.parameter-review-field,.parameter-review-name,.parameter-source-reference-heading){min-height:24px;line-height:24px;margin:0}
#parameterSourceReviewRows :is(.parameter-review-field,.parameter-review-name){display:flex;align-items:center;flex-wrap:wrap;gap:4px 8px}
#parameterSourceReviewRows .parameter-source-reference-heading{position:relative;align-items:center;padding-inline-start:24px}
#parameterSourceReviewRows .parameter-source-reference-heading input{position:absolute;inset-inline-start:0;top:4px;margin:0}
#parameterSourceReviewRows .parameter-source-reference-heading .metric-source-name code{line-height:24px}
#parameterSourceReviewRows :is(.parameter-review-field,.parameter-review-name,.parameter-source-field-detail) .source-state-badge{margin:0}
#parameterSourceReviewRows :is(.parameter-review-count,.parameter-source-field-detail),#parameterSourceReviewRows>tr>td:first-child>p{min-height:24px;line-height:24px;margin:4px 0 0}
#parameterSourceReviewRows .parameter-source-field-detail{margin-inline-start:24px;flex-wrap:wrap}

/* Parameter drawers share the metric editor's compact controls and spacing. */
.right-drawer.parameter-drawer{--parameter-control-height:32px}
.right-drawer.parameter-drawer #modalBody .form{gap:12px}
.right-drawer.parameter-drawer #modalBody .form label{gap:4px;min-width:0}
.right-drawer.parameter-drawer #modalBody .two{column-gap:16px;row-gap:10px}
.right-drawer.parameter-drawer #modalBody input:not([type=checkbox]):not([type=radio]):not([type=file]),
.right-drawer.parameter-drawer #modalBody select{box-sizing:border-box;height:var(--parameter-control-height);min-height:var(--parameter-control-height);padding:5px 8px;font-size:13px;line-height:20px;min-width:0}
.right-drawer.parameter-drawer #modalBody .editable-select>input:not([type=checkbox]):not([type=radio]):not([type=file]){padding-right:27px}
.right-drawer.parameter-drawer #modalBody textarea{font-size:13px;line-height:20px;padding:8px}
.right-drawer.parameter-drawer #modalBody :is(#parameterSourceRows input[data-parameter-label],input[data-source-option-label],input[data-merge-label]){font-size:12px;width:100%}
.right-drawer.parameter-drawer #modalBody input:is([type=checkbox],[type=radio]){width:16px;min-width:16px;height:16px;padding:0;flex:none}
.right-drawer.parameter-drawer #modalBody :is(.toolbar,.actions){gap:8px}
.right-drawer.parameter-drawer #modalBody :is(.toolbar,.actions)>button:not(.link),
.right-drawer.parameter-drawer #modalBody .list-pagination button{box-sizing:border-box;height:32px;min-height:32px;padding:5px 9px;font-size:13px;line-height:20px}
.right-drawer.parameter-drawer #modalActions{gap:9px}
.right-drawer.parameter-drawer #modalActions>button{font-size:13px;line-height:20.8px;padding:8px 13px}
.right-drawer :is(#downloadImportExample,#libraryFiles){box-sizing:border-box;height:32px;min-height:32px;padding:5px 9px;font-size:13px;line-height:20px}
.right-drawer #libraryFiles{padding:0 8px 0 0}
.right-drawer #libraryFiles::file-selector-button{height:30px;margin-right:8px;padding:4px 9px;font:inherit;color:#34425b;background:#f7f9fc;border:0;border-right:1px solid #d7deea}
.right-drawer .source-toolbar [data-template-option-search]{box-sizing:border-box;height:32px;min-height:32px;padding:5px 8px;font-size:13px;line-height:20px}

.merge-source-list{display:grid;gap:4px;min-width:0}
.merge-name-group{display:grid;grid-template-columns:7em 8px minmax(0,1fr);align-items:start;gap:6px;min-width:0}
.right-drawer .merge-name-choice{display:block;min-width:0;width:100%;height:32px;padding:6px 0;line-height:20px;text-align:left;font-size:13px;font-weight:400;color:#34425b;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;border:0;background:none}
.right-drawer .merge-name-choice:hover{color:#315bd6;text-decoration:underline;text-underline-offset:3px}
.right-drawer .merge-name-choice[aria-pressed=true]{color:#315bd6;font-weight:500}
.merge-source-dot{color:#94a3b8;line-height:32px;text-align:center}
.merge-model-single{display:block;min-width:0;height:32px;line-height:20px;padding:6px 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;background:none;color:#7b879a;font-size:13px}
.merge-models{min-width:0;font-size:13px}
.merge-models>summary{height:32px;line-height:20px;padding:6px 0;color:#64748b;cursor:pointer;white-space:nowrap}
.merge-models ul{list-style:none;margin:0 0 6px;padding:0;max-height:160px;overflow:auto}
.merge-models li{padding:4px 0;line-height:20px}
.merge-models code{font-size:13px;color:#7b879a;background:none;padding:0;overflow-wrap:anywhere}
.parameter-merge-table>tbody>tr>td:first-child>.merge-field-id{display:block;min-width:0;height:32px;font-size:13px;line-height:20px;padding:6px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:none}
.parameter-merge-table .merge-unified-column{width:46%}

/* Keep name reconciliation controls visible while only the field list scrolls. */
.right-drawer #modalBody:has(.parameter-merge-table){display:flex;flex-direction:column;overflow:hidden;gap:8px}
.merge-review-intro{flex:none;font-size:13px;line-height:20px;color:#475569}
.merge-review-intro p{margin:0 0 4px}
.merge-review-meta{display:flex;flex-wrap:wrap;gap:4px 20px;justify-content:space-between;font-size:12px;color:#7b879a}
.merge-review-meta strong{font-weight:500;color:#475569}
.right-drawer #modalBody:has(.parameter-merge-table)>.table-wrap{flex:1 1 0;min-height:0;max-height:none;overflow:auto;margin:0}
.parameter-merge-table{width:100%;table-layout:fixed}
.parameter-merge-table thead th{position:sticky;top:0;z-index:1;background:#f6f8fb}
.parameter-merge-table>tbody>tr>td{padding:6px 10px;vertical-align:top}
.parameter-merge-table>thead>tr>th{padding:7px 10px}
.parameter-merge-table .merge-source-list{gap:0}
.parameter-merge-table .merge-field-id{color:#334155}
.right-drawer:has(.parameter-merge-table) #modalActions{position:relative;inset:auto;background:#fff;z-index:2}

.parameter-merge-table .merge-model-single{min-height:26px;height:auto;padding:3px 0;white-space:normal;overflow:visible;overflow-wrap:anywhere;line-height:20px}
.parameter-merge-table .merge-models code{white-space:normal;overflow-wrap:anywhere}
.merge-result{display:grid;gap:0;min-width:0}
.merge-result-field{display:flex;align-items:baseline;gap:8px;min-height:26px;padding:3px 0;line-height:20px}
.merge-result-field .muted{flex:0 0 52px;font-size:12px;white-space:nowrap}
.parameter-merge-table .merge-result-field .merge-field-id{min-width:0;font-size:13px;line-height:20px;background:none;padding:0;white-space:nowrap;overflow-x:auto}
.merge-result-label{display:flex;align-items:center;gap:8px}
.merge-result-label>.muted{flex:0 0 52px;font-size:12px;white-space:nowrap}
.right-drawer.parameter-drawer #modalBody .merge-result-label input[data-merge-label]{width:146px;max-width:100%;min-width:0}

.merge-result{position:relative}
.merge-confirmation-badge{position:absolute;right:0;top:3px;font-size:11px;line-height:20px;padding:0 5px;border-radius:4px;background:#fff3d6;color:#946200}
.merge-result:has(.merge-confirmation-badge) .merge-result-field{padding-right:78px}

/* Keep parameter captions beside their controls; help is disclosed on demand. */
.parameter-edit-form .parameter-field{display:grid;grid-template-columns:104px minmax(0,1fr);align-items:center;gap:8px;min-width:0}
.parameter-edit-form .parameter-field-caption{display:flex;align-items:center;gap:6px;min-width:0}
.parameter-edit-form .parameter-field>label,.parameter-edit-form .parameter-field-caption>label{white-space:nowrap}
.parameter-edit-form .parameter-help{position:relative;flex:none}
.parameter-edit-form .parameter-help summary{display:flex;align-items:center;justify-content:center;width:18px;height:18px;border:1px solid #758298;border-radius:50%;color:#68758d;font-size:12px;line-height:1;cursor:pointer;list-style:none}
.parameter-edit-form .parameter-help summary::-webkit-details-marker{display:none}
.parameter-edit-form .parameter-help summary:focus-visible{outline:2px solid #a2b7fa;outline-offset:3px}
.parameter-edit-form .parameter-help small{position:absolute;top:26px;left:-72px;z-index:5;width:min(360px,calc(100vw - 100px));padding:12px 14px;background:#fff;border:1px solid #d7deea;border-radius:8px;box-shadow:0 6px 24px #1d315326;color:#52617a;font-size:13px;font-weight:400;white-space:normal;line-height:1.7}

.parameter-options-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}
.parameter-options-table td input{width:100%;min-width:110px}
.parameter-options-table .parameter-option-source{display:block;max-width:160px;white-space:normal;overflow-wrap:anywhere;font-size:12px;color:#68758d}
.parameter-options-table .parameter-option-usage{font-size:12px}
.parameter-options-table .parameter-option-removed{background:#f6f8fc;color:#8993a3}
.parameter-options-table .parameter-option-removed input{text-decoration:line-through}
.parameter-options-table th{position:sticky;top:0}

.parameter-option-models{margin:0}
.parameter-option-models summary{display:flex;align-items:center;gap:6px;cursor:pointer;list-style:none;white-space:nowrap;max-width:160px}
.parameter-model-first{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#68758d}
.parameter-option-models summary .parameter-model-first{flex:1}
.parameter-option-models .models-expand,.parameter-option-models .models-collapse{flex:none;color:#315bd6}
.parameter-option-models summary::-webkit-details-marker{display:none}
.parameter-option-models summary:focus-visible{outline:2px solid #a2b7fa;outline-offset:2px;border-radius:3px}
.parameter-option-models .models-collapse,.parameter-option-models[open] .models-expand{display:none}
.parameter-option-models[open] .models-collapse{display:inline}
.parameter-option-models ul{list-style:none;margin:6px 0 0;padding:0;display:grid;gap:6px}

/* Preserve the existing source option typography in the unified editor. */
.right-drawer.parameter-drawer #modalBody .parameter-options-table input[data-option-label]{font-size:12px}
.parameter-options-table .parameter-option-field{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;white-space:normal;overflow-wrap:anywhere}
.right-drawer.parameter-drawer #modalBody:has(>.parameter-edit-form .parameter-options-table){display:flex;padding-bottom:10px}
.right-drawer.parameter-drawer #modalBody>.parameter-edit-form:has(.parameter-options-table){display:flex;flex-direction:column;flex:1;min-width:0;min-height:min-content}
.parameter-edit-form>.parameter-options-table{flex:1;min-height:120px;max-height:none;overflow:auto}
.parameter-edit-form .parameter-option-filters{margin:0;flex-wrap:wrap;gap:8px}
.parameter-option-filters>.editable-select{flex:1;min-width:130px;width:0}
.parameter-edit-form>.parameter-options-table th,.parameter-edit-form>.parameter-options-table td{padding-top:4px;padding-bottom:4px}
.right-drawer.parameter-drawer #modalBody .parameter-options-table input{--parameter-control-height:28px;padding-top:3px;padding-bottom:3px}

.template-batch-actions.toolbar-batch-group{margin-left:0}
.toolbar-batch-menu{position:relative}
.toolbar-batch-menu summary{cursor:pointer;list-style:none;border:1px solid #d7deea;border-radius:6px;background:#fff;padding:5px 9px;white-space:nowrap}
.toolbar-batch-menu summary::-webkit-details-marker{display:none}
.toolbar-batch-menu>div{position:absolute;z-index:8;inset-inline-start:0;display:grid;min-width:112px;margin-top:4px;padding:4px;border:1px solid #d7deea;border-radius:6px;background:#fff;box-shadow:0 4px 12px #1d315329}
.toolbar-batch-menu button{border:0;text-align:left}
.toolbar-batch-menu .danger{border-top:1px solid #e5eaf2;border-radius:0;color:#bc3547}
.list-source-sync{display:flex;align-items:center;gap:8px;margin-left:auto}
.list-source-sync #sourceRefreshSummary{position:relative;white-space:nowrap}
.list-source-sync #sourceRefreshSummary[data-full-time]:not([data-full-time=""]):is(:hover,:focus-visible)::after{content:attr(data-full-time);position:absolute;z-index:5;top:100%;right:0;padding:4px 8px;border-radius:4px;background:#24324a;color:#fff;pointer-events:none}

#parameterSourceReviewRows .parameter-view-change{margin-inline-start:auto}
#parameterSourceReviewRows .parameter-source-change-row>td{padding:8px 12px;font-size:12px;line-height:18px;background:#f7f9fc;white-space:normal;overflow-wrap:anywhere}
.parameter-source-change-row .source-change-review{margin-top:4px}
#parameterSourceReviewRows .parameter-source-change-row .source-change-table :is(th,td){padding:5px 8px;font-size:12px;line-height:18px}
.parameter-source-change-row .source-change-json{margin-top:6px}
.source-json-tabs{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px;border-bottom:1px solid #dfe5ef}
.right-drawer .source-json-tabs button{font-size:12px;line-height:18px;padding:4px 8px;border:0;border-radius:0;background:transparent}
.right-drawer .source-json-tabs button[aria-selected="true"]{border-bottom:2px solid #315bd6;color:#315bd6}
.parameter-source-change-row pre{max-height:280px;margin:6px 0 0;padding:8px 10px;font-size:12px;line-height:18px;white-space:pre-wrap;overflow-wrap:anywhere}

.parameter-source-review-actions{margin:8px 0 0}
.parameter-source-review-actions>span{flex:1 1 260px}

/* SQL option generation is scoped to the select-parameter editor. */
.parameter-sql-config{display:grid;gap:10px;margin:0}
.parameter-sql-config>.sql-section-heading{margin:0;min-height:32px}
.parameter-sql-config #paramExecuteSql{height:32px;min-height:32px;padding:0 12px;line-height:30px;box-sizing:border-box}
.parameter-sql-config #paramSqlStatus:empty{display:none}
.parameter-sql-layout{display:block}
.parameter-sql-layout .template-edit-sql{min-width:0}
.parameter-sql-preview-table{max-height:240px;overflow:auto}

.parameter-edit-form .source-state-badge.error{background:#fdeced;color:#ae3a49}
/* Keep the SQL text and highlight aligned beyond the gutter inside the drawer. */
#modalBody .parameter-sql-config .sql-editor :is(textarea[data-sql-editor],.sql-highlight){padding:12px 88px 12px 64px;font-size:12px;line-height:20px}
#modalBody .parameter-sql-config .sql-line-numbers>div{padding:12px 10px;font-size:12px;line-height:20px}

.parameter-sql-filter-toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.parameter-sql-filter-toolbar>.template-filters{flex:1;display:grid;grid-template-columns:1.35fr 1fr 1fr;gap:8px;min-width:0;margin:0}
.parameter-sql-filter-toolbar .template-multiselect{min-width:0;width:100%}
.parameter-sql-filter-toolbar>button{height:32px;padding:0 10px;font-size:13px}
.parameter-sql-layout .template-edit-sql{min-height:0}
@media(max-width:600px){.parameter-sql-filter-toolbar>.template-filters{flex-basis:100%;grid-template-columns:1fr}}

.parameter-sql-preview-table th{text-align:left}
.parameter-sql-change{display:inline-block;padding:3px 8px;border-radius:5px;font-size:12px;line-height:18px}
.parameter-sql-change.added{background:#e8f7ee;color:#16794b}
.parameter-sql-change.existing{background:#eaf1ff;color:#315bd6}
.parameter-sql-change.conflict{background:#fff1e6;color:#a64b00}
.parameter-sql-conflict-note{display:block;white-space:normal;max-width:360px;color:#a64b00;margin-top:4px}
.parameter-sql-change-filters{margin-bottom:10px;gap:10px}
.parameter-sql-change-filters .template-multiselect{width:180px;flex:none}

.parameter-sql-change.existing,.parameter-sql-change.preserved{background:#f0f2f5;color:#667085}
.parameter-sql-change.renamed{background:#eaf1ff;color:#315bd6}
.parameter-sql-change.removed{background:#fff1e6;color:#a64b00}
.parameter-sql-change.blocked,.parameter-sql-change.conflict{background:#fdeced;color:#b42318}

.parameter-sql-config>.sql-section-heading{flex-wrap:wrap}
.right-drawer.parameter-drawer .parameter-sql-config .parameter-sql-distinct{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;cursor:pointer}
#modalBody #paramSqlDistinct{appearance:none;width:30px;height:18px;min-width:30px;max-width:30px;min-height:18px;max-height:18px;flex:0 0 30px;margin:0;box-sizing:border-box;padding:0;border:0;border-radius:10px;background:#98a2b3;position:relative;cursor:pointer}
#modalBody #paramSqlDistinct::after{content:"";position:absolute;top:2px;left:2px;width:14px;height:14px;border-radius:50%;background:white}
#modalBody #paramSqlDistinct:checked{background:#315bd6}
#modalBody #paramSqlDistinct:checked::after{left:14px}
#modalBody #paramSqlDistinct:disabled{opacity:.45;cursor:not-allowed}

.parameter-sql-editor-tools{display:flex;align-items:center;gap:12px;flex-wrap:wrap;min-height:20px}

/* Parameter option SQL only: five rows initially, with native vertical resizing. */
.parameter-sql-layout .template-edit-sql>.sql-editor:not(.workspace-expanded){flex:none}
.parameter-sql-layout .sql-editor:not(.workspace-expanded)>#paramOptionsSql{height:auto;min-height:104px;max-height:none;resize:vertical}

.parameter-sql-execute-actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap}

.parameter-sql-execute-actions #paramSqlCheckedAt{margin-left:auto;white-space:nowrap}
.parameter-sql-config #paramSqlPreview:not(:empty){border-top:1px solid #e9edf4;padding-top:12px;margin-top:2px}
.parameter-sql-config #paramSqlPreview>p:first-child{margin-top:0}

/* Compact parameter SQL results, including the expanded preview. */
#paramSqlPreview .parameter-sql-preview-table :is(th,td){padding:6px 12px;line-height:20px}
#paramSqlPreview .parameter-sql-change{padding:1px 8px}
#paramSqlPreview .parameter-sql-change-filters>.expand-view-icon{margin-left:auto}
#paramSqlPreview.workspace-expanded:popover-open{display:flex;flex-direction:column;padding:20px;gap:10px;margin:0;border:0;overflow:hidden}
#paramSqlPreview.workspace-expanded>p{margin:0;flex:none}
#paramSqlPreview.workspace-expanded>.parameter-sql-change-filters{flex:none;margin:0}
#paramSqlPreview.workspace-expanded>.parameter-sql-preview-table{flex:1;min-height:0;max-height:none;background:white}
#paramSqlPreview.workspace-expanded .parameter-sql-preview-table th{position:sticky;top:0;z-index:1;background:#f5f7fb}

#paramSqlPreview .parameter-sql-preview-notice{color:#315bd6}

.parameter-sql-config #paramSqlStatus:not(.error){color:#315bd6}
#paramSqlPreview [data-sql-change="existing"] .parameter-sql-conflict-note{color:#68758d}

/* Keep model-name choices aligned with the compact field confirmation rows. */
.right-drawer .parameter-merge-table .merge-name-choice,.parameter-merge-table .merge-models>summary{height:26px;padding:3px 0;line-height:20px}
.parameter-merge-table .merge-source-dot{line-height:26px}

/* Leave more room for options by tightening only the parameter form header. */
.right-drawer.parameter-drawer #modalBody>.parameter-edit-form{gap:8px}
.parameter-edit-form>p.muted{margin:0;line-height:18px}
.parameter-edit-form>small.muted{line-height:18px}

/* Show metric/template associations without restricting other choices. */
.grid-association-hint{font-size:12px;line-height:18px;color:#64748b}
.grid-template-choices button.grid-option-linked,.grid-template-choices button.grid-option-linked[aria-pressed=true]{background:#ecfdf3;color:#166534}
.grid-template-choices button.grid-option-linked:hover{background:#dcfce7}
.grid-template-choices button.grid-option-linked.grid-option-unavailable,.grid-template-choices button.grid-option-linked.grid-option-unavailable[aria-pressed=true]{background:#f3f5f8;color:#8a94a5}
.grid-template-choices button.grid-option-linked.grid-option-unavailable:hover{background:#eef1f5}
.grid-association-label{font-size:11px;font-style:normal;margin-left:8px}
.grid-template-choices button:disabled{opacity:.5;cursor:not-allowed}
.grid-template-choices button.grid-option-linked:disabled{opacity:1}
.question-sheet .grid-template-choices button:is(:hover,:focus-visible){white-space:normal;overflow:visible;text-overflow:clip;overflow-wrap:anywhere}
