/* Analytix, xperitus graphical profile, look "Option A": dark blue header, white
   workspace, orange (brand red #FF4330) for actions and active states.
   Palette (brandbook): dark blue #1E274A, light blue #D8ECE9, blue-green #47A8A4,
   red #FF4330 (accent, sparingly), grey 1 #3A3B3B, grey 2 #828586.
   Tints in 20% steps only. Font: Jost (Arial fallback). */
:root {
  --dark: #1E274A;
  --dark-80: #4B526E;        /* secondary text, passes 4.5:1 on white */
  --dark-40: #A5A9B7;        /* input borders */
  --dark-20: #D2D4DB;        /* panel borders */
  /* Crisp theme (0.10): neutral greys instead of light blue, so dark blue + orange stand out. */
  --light: #E8EAF0;          /* chips, soft fills (dark blue 10%) */
  --light-60: #F1F2F5;
  --light-40: #F4F5F7;       /* page ground */
  --light-80: #E8EAF0;       /* hairlines */
  --bg: #F4F5F7;
  --line: #DFE2E7;           /* card and panel borders */
  --muted: #5B6274;          /* secondary text, 6:1 on white */
  --green: #47A8A4;
  --red: #FF4330;
  --grey1: #3A3B3B;
  --orange: #FF4330;
  --orange-40: #FFB4AC;
  --orange-20: #FFD9D6;
  --grey-10: #E9EAED;    /* dark blue 10% */
  --radius: 3px;
  --font: Jost, Arial, sans-serif;
  --mono: ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--dark); background: #fff; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--dark); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
input[type=checkbox], input[type=radio] { accent-color: var(--orange); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; height: 38px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--dark); background: #fff; cursor: pointer; }
.btn:hover { background: var(--grey-10); }
/* Main call to action. White on brand orange is 3.4:1, so the text is large and bold
   (19px / 700 counts as large text, which needs 3:1). */
.btn-cta { height: 42px; padding: 0 22px; border: 0; border-radius: var(--radius); background: var(--orange); color: #fff; font-size: 19px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.btn-cta:hover { background: #E63A28; }
.btn-cta:disabled { background: var(--orange-40); color: var(--dark); cursor: not-allowed; }
.btn-primary { background: var(--dark); color: #fff; border-color: var(--dark); font-weight: 500; }
.btn-primary:hover { background: #2f3a63; }
.btn-primary:disabled { opacity: .55; cursor: progress; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-small { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-dashed { border: 1px dashed var(--orange); background: #fff; }
.input, .select { height: 36px; border: 1px solid var(--dark-40); border-radius: var(--radius); padding: 0 10px; background: #fff; }
.input:focus, .select:focus { border-color: var(--dark); }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: var(--radius); background: transparent; cursor: pointer; }
.icon-btn:hover { border-color: var(--dark-20); background: #fff; }
.icon-btn svg { width: 14px; height: 14px; stroke: var(--dark); fill: none; stroke-width: 1.5; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; background: var(--dark); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 34px; }
.login-logo { height: 46px; width: auto; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: var(--radius); border: 1px solid var(--dark-20); padding: 22px 20px 20px; display: flex; flex-direction: column; gap: 6px; }
.login-card h1 { margin: 0 0 10px; font-size: 19px; font-weight: 600; }
.login-card label { font-size: 13px; font-weight: 500; color: var(--dark-80); margin-top: 8px; display: flex; align-items: center; gap: 4px; }
.login-card .input, .login-card .select { width: 100%; height: 40px; font-size: 15px; }
.login-card .input { background: #EDF3FB; }
.info { width: 15px; height: 15px; display: inline-grid; place-items: center; border: 1.3px solid var(--dark-80); border-radius: 50%; font-size: 10px; font-weight: 600; cursor: help; }
.btn-login { margin-top: 16px; height: 44px; border: 0; border-radius: var(--radius); background: var(--orange); color: #fff; font-weight: 700; font-size: 19px; cursor: pointer; }
.btn-login:disabled { opacity: .65; cursor: progress; }
.form-error { margin-top: 10px; padding: 9px 11px; border-radius: var(--radius); background: #FFE3E0; color: #7A1A10; font-size: 13px; line-height: 1.4; }

/* ---------- app shell ---------- */
.topbar { background: var(--dark); color: #fff; padding: 10px 28px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
.brand { display: flex; align-items: center; gap: 16px; flex: 1 1 260px; }
.brand img { height: 28px; width: auto; display: block; }
.brand .divider { width: 1px; height: 24px; background: var(--dark-80); }
.brand .product { font-weight: 300; font-size: 22px; color: var(--light); text-decoration: none; }
.topbar .right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.env-tag { border: 1px solid var(--orange); color: #fff; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: var(--radius); letter-spacing: .04em; }
.topbar a, .topbar .btn-ghost { color: #fff; text-decoration: none; }
.topbar .btn-ghost { height: 34px; border: 1px solid #4B526E; }
.topbar .btn-ghost:hover { background: #2f3a63; }
.mainnav { display: flex; gap: 22px; align-items: center; }
.mainnav a { color: var(--light); text-decoration: none; padding: 8px 0; }
.mainnav a:hover { color: #fff; }
.mainnav a[aria-current="page"] { color: #fff; font-weight: 500; box-shadow: inset 0 -3px 0 var(--orange); }

.titlebar { background: #fff; padding: 20px 28px 4px; display: flex; align-items: center; gap: 12px; }
.titlebar .bar { width: 4px; height: 28px; background: var(--orange); }
.titlebar h1 { margin: 0; font-weight: 300; font-size: 32px; }
.titlebar { flex-wrap: wrap; }
.titlebar h1 { flex: 1 1 300px; }
.title-actions { display: flex; gap: 10px; align-items: center; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 190px; background: #fff; border: 1px solid var(--dark-20); border-radius: var(--radius); box-shadow: 0 6px 18px rgba(30, 39, 74, .14); padding: 4px; display: flex; flex-direction: column; }
.menu button { text-align: left; padding: 9px 12px; border: 0; background: transparent; border-radius: var(--radius); cursor: pointer; font-size: 14px; }
.menu button:hover, .menu button:focus-visible { background: var(--light); }
.chip-label { border: 0; background: transparent; color: inherit; font: inherit; padding: 2px 4px; border-radius: var(--radius); min-width: 40px; }
.chip-label:hover { background: rgba(255,255,255,.35); }
.chip.mea .chip-label:hover { background: rgba(255,255,255,.12); }
.chip.dim .chip-label:focus, .chip.mea .chip-label:focus, .chip-label:focus { outline: 2px solid var(--orange); background: #fff; color: var(--dark); }
.chip.mea:focus-within { background: #fff; color: var(--dark); box-shadow: inset 0 0 0 1px var(--dark); }
.chip.mea:focus-within select { background: var(--grey-10); }
.chip .grip { font-size: 11px; letter-spacing: -2px; opacity: .55; cursor: grab; margin-right: -2px; }
.chip[draggable="true"] { cursor: grab; }
.shelf.drop-here { border-color: var(--orange); border-style: solid; background: var(--orange-20); }
.field[draggable="true"] { cursor: grab; }
.kpi { position: relative; }
.kpi-x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border: 0; border-radius: var(--radius); background: transparent; color: var(--dark-80); font-size: 16px; cursor: pointer; }
.kpi-x:hover { background: var(--grey-10); }
.kpi-picks { display: flex; flex-wrap: wrap; gap: 6px 18px; padding-left: 26px; }
table.grid tbody tr:not(.total):hover td { background: var(--light); }
table.grid th[draggable="true"] { cursor: grab; }
table.grid th.drop-before { box-shadow: inset 3px 0 0 var(--orange); }
.chart-head { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.chart-head h3 { flex: 1; margin: 0; }
.chart-head .icon-btn { width: 28px; height: 28px; color: var(--dark-80); }

.workspace { display: flex; flex-wrap: wrap; gap: 20px; padding: 20px 28px; align-items: flex-start; }
.panel { background: #fff; border: 1px solid var(--dark-20); border-radius: var(--radius); }
.panel-head { font-size: 15px; font-weight: 500; }
.muted { color: var(--dark-80); font-size: 13px; }

/* ---------- fields panel ---------- */
.fields-panel { flex: 1 1 300px; max-width: 360px; min-width: 280px; display: flex; flex-direction: column; }
.source-box { padding: 16px; border-bottom: 1px solid var(--light-80); display: flex; flex-direction: column; gap: 8px; }
.source-row { display: flex; gap: 8px; }
.source-row .input { flex: 1; min-width: 0; text-transform: uppercase; }
.field-search { padding: 12px 16px 6px; }
.field-search .input { width: 100%; }
.field-list-head { display: grid; grid-template-columns: minmax(0, 1fr) 52px 58px 32px; gap: 4px; padding: 6px 16px; font-size: 12px; color: var(--dark-80); }
.field-list-head span:nth-child(n+2) { text-align: center; }
.field-group { padding: 10px 16px 4px; font-size: 15px; font-weight: 500; border-top: 1px solid var(--light-80); }
.field-list { list-style: none; margin: 0; padding: 0 8px 10px; max-height: 62vh; overflow-y: auto; }
.field { display: grid; grid-template-columns: minmax(0, 1fr) 52px 58px 32px; gap: 4px; align-items: center; padding: 5px 8px; border-radius: var(--radius); }
.field:hover { background: var(--grey-10); }
.field .name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.field .label { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; }
.field .tag { font-size: 11px; color: var(--dark-80); white-space: nowrap; }
.field .check { display: grid; place-items: center; }
.field input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--orange); cursor: pointer; }
.alias { font-family: var(--mono); font-size: 11px; padding: 2px 5px; border-radius: 3px; min-width: 42px; text-align: center; flex: none; }
.alias.dim { background: var(--light); color: var(--dark); }
.alias.mea { background: var(--dark); color: #fff; }
.field-label-wrap { display: flex; flex-direction: column; min-width: 0; }

.wide-input { width: 100%; }
.source-filters { display: flex; gap: 6px; margin-top: 8px; }
.source-filters .select { flex: 1; min-width: 0; height: 32px; font-size: 13px; }
.obj-results { list-style: none; margin: 8px 0 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.obj-results:empty { display: none; }
.obj-result { display: flex; flex-direction: column; gap: 2px; padding: 7px 8px; border-radius: var(--radius); cursor: pointer; }
.obj-result:hover, .obj-result.active { background: var(--light); }
.obj-result .top { display: flex; align-items: center; gap: 8px; }
.obj-result .desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.obj-result .meta { font-size: 12px; color: var(--dark-80); padding-left: 2px; }
.obj-more { font-size: 12px; color: var(--dark-80); padding: 6px 8px; }
.selected-source { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.sel-main { font-size: 15px; font-weight: 500; }

/* ---------- query + results ---------- */
.main-col { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.query { padding: 16px 18px; display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 12px 14px; align-items: start; }
.query .row-label { font-size: 15px; font-weight: 500; padding-top: 7px; }
.shelf { display: flex; flex-wrap: wrap; gap: 8px; min-height: 40px; border: 1px dashed var(--dark-40); border-radius: var(--radius); padding: 5px; align-items: center; }
.shelf .empty { font-size: 13px; color: var(--dark-80); padding: 0 6px; }
.chip { height: 32px; display: inline-flex; align-items: center; gap: 6px; padding: 0 4px 0 12px; border-radius: var(--radius); font-size: 14px; }
.chip.dim { background: var(--light); }
.chip.mea { background: var(--dark); color: #fff; }
.chip select { height: 24px; border: 0; border-radius: var(--radius); padding: 0 2px; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.15); color: inherit; }
.chip.mea select option { color: var(--dark); }
.chip .x { width: 24px; height: 24px; border: 0; background: transparent; color: inherit; cursor: pointer; border-radius: var(--radius); font-size: 16px; line-height: 1; }
.chip .x:hover { background: rgba(0,0,0,.08); }
.chip.mea .x:hover { background: rgba(255,255,255,.15); }
.chip label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.filters { display: flex; flex-direction: column; gap: 6px; }
.filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 8px; background: #fff; border: 1px dashed var(--orange); border-radius: var(--radius); }
.filter .fname { font-weight: 500; min-width: 120px; }
.filter .select, .filter .input { height: 32px; }
.filter .input { width: 160px; }
.filter .input.wide { width: 240px; }
.sortrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sortrow .input { width: 70px; }
.run-row { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 4px; border-top: 1px solid var(--light-80); }
.plan { font-size: 13px; color: var(--dark-80); }

.results { padding: 16px 18px; display: flex; flex-direction: column; gap: 16px; }
.results-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.results-head h2 { margin: 0; font-size: 22px; font-weight: 300; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--dark-20); border-top: 4px solid var(--orange); border-radius: var(--radius); padding: 14px 16px; }
.kpi .k-label { font-size: 13px; color: var(--dark-80); }
.kpi .k-value { font-size: 30px; font-weight: 300; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chart { display: flex; flex-direction: column; gap: 6px; }
.chart h3 { margin: 0 0 2px; font-size: 15px; font-weight: 500; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 220px) minmax(0, 1fr) 130px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .b-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--grey-10); height: 16px; border-radius: 3px; }
.bar { background: var(--green); height: 16px; border-radius: 3px; }
.bar.neg { background: var(--dark-40); }
.bar-row .b-val { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--light-80); border-radius: var(--radius); max-height: 70vh; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th { position: sticky; top: 0; background: var(--dark); color: #fff; font-weight: 500; text-align: left; padding: 9px 12px; white-space: nowrap; }
table.grid th button { all: unset; cursor: pointer; }
table.grid th button:focus-visible { outline: 2px solid var(--green); }
table.grid td { padding: 7px 12px; border-bottom: 1px solid var(--light-80); white-space: nowrap; }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.total td { background: var(--grey-10); font-weight: 500; position: sticky; bottom: 0; }
.notice { padding: 9px 11px; border-radius: var(--radius); background: var(--light); font-size: 13px; line-height: 1.45; }
.notice.error { background: #FFE3E0; color: #7A1A10; white-space: pre-wrap; }
.empty-state { padding: 36px 18px; text-align: center; color: var(--dark-80); }
.empty-state strong { display: block; color: var(--dark); font-size: 18px; font-weight: 400; margin-bottom: 6px; }

.tabs { display: flex; gap: 4px; margin-bottom: -18px; }
.tab { height: 42px; padding: 0 20px; border: 1px solid transparent; border-bottom: 0; border-radius: var(--radius) 8px 0 0; background: transparent; cursor: pointer; font-size: 15px; }
.tab[aria-selected="true"] { background: #fff; border-color: var(--dark-20); font-weight: 500; box-shadow: inset 0 -3px 0 var(--orange); position: relative; top: 1px; }
.layout { padding: 16px 18px; display: flex; flex-direction: column; gap: 18px; }
.lay-section { display: flex; flex-direction: column; gap: 10px; }
.lay-section + .lay-section { border-top: 1px solid var(--light-80); padding-top: 16px; }
.lay-section h3 { margin: 0; font-size: 20px; font-weight: 300; }
.check-line { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check-line input { width: 18px; height: 18px; accent-color: var(--orange); }
.lay-card { border: 1px solid var(--dark-20); background: #fff; border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.lay-card-head { display: flex; align-items: center; gap: 4px; }
.lay-card-head .spacer { flex: 1; }
.lay-grid { display: grid; grid-template-columns: 60px minmax(0, 1fr) 60px minmax(0, 1fr); gap: 8px 10px; align-items: center; }
.lay-grid .select, .lay-grid .input { width: 100%; height: 34px; }
.lay-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 22px 28px; }
.chart { margin: 0; min-width: 0; }
.pie-wrap { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
svg.pie { width: 190px; height: 190px; flex: none; }
.legend { list-style: none; margin: 0; padding: 0; flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.legend li { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto 52px; gap: 8px; align-items: center; }
.legend .swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--dark-20); }
.legend .l-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .l-val, .legend .l-pct { text-align: right; font-variant-numeric: tabular-nums; }
.legend .l-pct { color: var(--dark-80); }

/* ---------- modes: home (landing / run) and designer ---------- */
body.mode-home .designer-frame, body.mode-home .fields-panel, body.mode-home .tabs, body.mode-home #queryNav, body.mode-home #queryPanel, body.mode-home #layoutPanel, body.mode-home #optionsPanel, body.mode-home .designer-only { display: none !important; }
body.mode-designer .home-only { display: none !important; }
.menu-toggle { width: 42px; height: 42px; flex: none; border: 1px solid var(--dark); border-radius: var(--radius); background: #fff; cursor: pointer; display: inline-grid; place-items: center; }
.menu-toggle svg path { stroke: var(--dark); stroke-width: 1.8; }
.menu-toggle[aria-expanded="true"] { background: var(--dark); }
.menu-toggle[aria-expanded="true"] svg path { stroke: #fff; }
.title-block h1 { flex: none; margin: 0; }
.title-block { flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.crumb { font-size: 13px; color: var(--dark-80); min-height: 0; }
.crumb:empty { display: none; }
.title-sub { font-size: 14px; color: var(--dark-80); }
.title-sub:empty { display: none; }
.title-sub .link { background: none; border: 0; padding: 0; color: var(--dark); text-decoration: underline; cursor: pointer; font: inherit; }
.title-sub .unsaved { color: #A3200F; }
.title-input { font: inherit; font-weight: 300; font-size: 32px; color: var(--dark); border: 0; border-bottom: 1px dashed var(--dark-40); padding: 0 0 2px; background: transparent; width: 100%; max-width: 760px; }
.title-input:focus { outline: none; border-bottom: 2px solid var(--orange); }
.titlebar .bar { display: none; }
.split { display: inline-flex; }
.split #saveBtn { border-radius: var(--radius) 0 0 var(--radius); font-weight: 500; }
.split .split-arrow { border-radius: 0 var(--radius) var(--radius) 0; border-left: 0; padding: 0 10px; }
.scrim { position: fixed; inset: 0; background: rgba(30, 39, 74, .35); z-index: 30; }
.reports-menu { position: fixed; left: 0; top: 0; bottom: 0; width: min(340px, 90vw); background: var(--dark); color: #fff; z-index: 31; padding: 18px 14px; display: flex; flex-direction: column; gap: 12px; box-shadow: 8px 0 24px rgba(30,39,74,.3); padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
.rm-head { display: flex; align-items: center; padding: 0 4px; }
.rm-head span { flex: 1; font-size: 22px; font-weight: 300; }
.rm-close { width: 34px; height: 34px; border: 0; background: transparent; color: var(--light); font-size: 24px; cursor: pointer; border-radius: var(--radius); }
.rm-close:hover { background: #2C3660; }
.rm-close.dark { color: var(--dark-80); }
.rm-close.dark:hover { background: var(--grey-10); }
.rm-search { height: 38px; border-radius: var(--radius); border: 0; background: #2C3660; color: #fff; padding: 0 12px; }
.rm-search::placeholder { color: var(--light); }
.rm-tree { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.rm-folder { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--radius); background: transparent; color: #fff; font-weight: 500; cursor: pointer; text-align: left; }
.rm-folder:hover { background: #2C3660; }
.rm-folder .count { margin-left: auto; font-size: 12px; color: var(--light); font-weight: 400; }
.rm-report { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px 7px 38px; border: 0; border-radius: var(--radius); background: transparent; color: #fff; cursor: pointer; text-align: left; }
.rm-report:hover { background: #2C3660; }
.rm-report[aria-current="true"] { background: #fff; color: var(--dark); font-weight: 500; }
.rm-report .rname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-report .lock { font-size: 11px; opacity: .8; }
.rm-empty { color: var(--light); font-size: 13px; padding: 4px 10px 8px 38px; }
.rm-foot { font-size: 12px; color: var(--light); }
.star { color: var(--dark-40); }
.star.on { color: var(--orange); }
.info-card { position: fixed; z-index: 32; left: min(370px, 5vw); top: 120px; width: min(560px, 90vw); max-height: calc(100vh - 150px); overflow-y: auto; background: #fff; border-radius: var(--radius); border-top: 4px solid var(--orange); box-shadow: 0 18px 50px rgba(30,39,74,.35); padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 900px) { .info-card { left: 5vw; } }
.info-card h2 { margin: 0; font-weight: 300; font-size: 26px; }
.info-grid { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 7px 12px; font-size: 14px; }
.info-grid dt { color: var(--dark-80); }
.info-grid dd { margin: 0; }
.info-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.save-dialog { width: min(580px, calc(100vw - 32px)); border: 0; border-radius: var(--radius); padding: 0; box-shadow: 0 18px 50px rgba(30,39,74,.35); color: var(--dark); }
.save-dialog::backdrop { background: rgba(30, 39, 74, .45); }
.sd-head { padding: 20px 24px 6px; display: flex; align-items: center; gap: 10px; }
.sd-head .bar { width: 4px; height: 24px; background: var(--orange); }
.sd-head h2 { margin: 0; font-weight: 300; font-size: 26px; flex: 1; }
.sd-body { padding: 10px 24px 4px; display: flex; flex-direction: column; gap: 14px; }
.sd-foot { padding: 16px 24px 20px; display: flex; justify-content: flex-end; gap: 10px; }
.field-block { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.field-block .input { width: 100%; height: 40px; font-size: 15px; font-weight: 400; }
.field-block .muted { font-weight: 400; }
.textarea { height: auto !important; padding: 10px 12px; resize: vertical; font-size: 14px !important; line-height: 1.4; }
.req { color: var(--orange); }
.name-check { font-size: 13px; font-weight: 400; min-height: 18px; }
.name-check.ok { color: #1F6F6B; }
.name-check.bad { color: #A3200F; }
.toggles { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--dark-20); border-radius: var(--radius); }
.toggle-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; cursor: pointer; }
.toggle-row + .toggle-row { border-top: 1px solid var(--grey-10); }
.toggle-row > span { display: flex; flex-direction: column; gap: 2px; }
.toggle-row strong { font-weight: 500; }
.toggle-row.disabled { opacity: .5; cursor: not-allowed; }
input.switch { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; flex: none; border-radius: 11px; background: var(--dark-40); position: relative; cursor: pointer; margin: 1px 0 0; transition: background .15s; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
input.switch:checked { background: var(--orange); }
input.switch:checked::after { left: 19px; }
input.switch:disabled { cursor: not-allowed; }
.versions { display: flex; flex-direction: column; }
.version-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--grey-10); font-size: 13px; }
.version-row .v { font-weight: 600; }
.version-row .v.current { color: var(--orange); }
.opt-grid .span-2 { grid-column: 1 / -1; }
.opt-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 20px; }
@media (max-width: 800px) { .opt-grid { grid-template-columns: 1fr; } }
.danger { color: #A3200F; border-color: #A3200F; }
.landing-empty { padding: 36px 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--dark-80); }
.landing-empty strong { color: var(--dark); font-size: 20px; font-weight: 300; }

/* ---------- joins ---------- */
.query-nav { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--grey-10); }
.qnav { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 12px; border: 1px solid var(--dark-20); border-radius: var(--radius); background: #fff; cursor: pointer; text-align: left; max-width: 340px; }
.qnav:hover { background: var(--grey-10); }
.qnav.active { border: 2px solid var(--orange); padding: 3px 11px; }
.qnav .qname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qnav .qsub { font-size: 12px; color: var(--dark-80); white-space: nowrap; }
.qnav.add { border-style: dashed; border-color: var(--orange); }
.qnav.add:disabled { opacity: .5; cursor: not-allowed; }
.qtag { padding: 2px 8px; border-radius: var(--radius); background: var(--dark); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .03em; white-space: nowrap; }
.qnav.join .qtag, .qtag.join { background: var(--orange); }
.join-editor { grid-column: 1 / -1; border: 2px solid var(--orange); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.jhead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.jhead .input { width: 200px; font-weight: 500; }
.jhead .spacer { flex: 1; }
.jrow { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; align-items: start; }
.jlabel { font-weight: 500; padding-top: 8px; }
.jcol { display: flex; flex-direction: column; gap: 8px; }
.join-types { display: flex; flex-wrap: wrap; gap: 8px; }
.jt { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--dark-40); border-radius: var(--radius); background: #fff; cursor: pointer; font-size: 13px; }
.jt.on { border: 2px solid var(--orange); padding: 5px 11px; font-weight: 500; }
.venn-line { fill: none; stroke: var(--dark); stroke-width: 1.2; }
.venn-fill { fill: var(--dark-40); opacity: .6; }
.jt.on .venn-fill { fill: var(--orange); opacity: .9; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr) minmax(110px, auto) 32px; gap: 8px; align-items: center; }
.pair .select { width: 100%; background: var(--light); border-color: var(--light); }
.pair .eq { text-align: center; font-weight: 700; color: #1F6F6B; }
.tc { font-size: 12px; }
.tc.ok { color: #1F6F6B; }
.tc.warn { color: #6B3A00; }
.suggest { padding: 7px 10px; border-radius: var(--radius); background: var(--orange-20); font-size: 13px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--dark); text-decoration: underline; cursor: pointer; font: inherit; font-size: 13px; align-self: flex-start; }
.drag-keys { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; border: 1px dashed var(--dark-40); border-radius: var(--radius); background: var(--grey-10); }
.keychip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius); background: var(--light); font-size: 13px; cursor: grab; }
.field.drop-key { outline: 2px solid var(--orange); background: var(--orange-20); }
.radio-line { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.radio-line input { accent-color: var(--orange); width: 16px; height: 16px; }
.notice.warn { background: #FFF4E0; color: #6B3A00; }
.key-note { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; padding: 1px 5px; border-radius: 3px; background: #fff; color: var(--dark-80); }
@media (max-width: 700px) { .jrow { grid-template-columns: 1fr; } .pair { grid-template-columns: 1fr; } }

/* ---------- custom fields ---------- */
.calc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.alias.calc { background: var(--orange-20); color: var(--dark); font-style: italic; }
.field.calc { grid-template-columns: minmax(0, 1fr) 52px 58px 64px; }
.calc-actions { display: flex; }
.calc-actions .icon-btn { width: 28px; height: 28px; }
.calc-dialog { width: min(680px, calc(100vw - 32px)); }
.cd-body { display: flex; flex-direction: column; gap: 12px; }
.cd-fields { display: flex; flex-direction: column; gap: 6px; }
.cd-row { display: flex; gap: 6px; align-items: center; }
.cd-row .select { flex: 1; }
.cd-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cd-insert { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cd-insert .select { flex: 1 1 260px; min-width: 0; height: 32px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.mono { font-family: var(--mono) !important; font-size: 13px !important; }
.field-block .select { width: 100%; height: 40px; font-weight: 400; }

/* ---------- more charts ---------- */
.svg-wrap { width: 100%; overflow-x: auto; }
svg.colchart, svg.mapchart { width: 100%; height: auto; display: block; }
svg.colchart .axis { font-size: 11px; fill: var(--dark-80); font-family: var(--font); }
svg.colchart .grid-line { stroke: var(--grey-10); }
svg.colchart .zero-line { stroke: var(--dark-40); }
.bar-track.stack { display: flex; overflow: hidden; }
.bar-track.stack .seg { height: 16px; }
.bar-track.stack .seg:first-child { border-radius: 3px 0 0 3px; }
.legend.inline { flex-direction: row; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; }
.legend.inline li { display: inline-flex; gap: 6px; grid-template-columns: none; }
.map-legend { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; }
.map-step { width: 26px; height: 10px; display: inline-block; }
svg.mapchart .map-label { fill: var(--dark); font-family: var(--font); paint-order: stroke; stroke: #fff; stroke-width: 0.25px; }
.lay-card > .lay-grid + .lay-grid { margin-top: 2px; }

/* ---------- console ---------- */
.console { padding: 18px 24px; display: flex; flex-direction: column; gap: 18px; max-width: 1200px; }
.console section { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.console h2 { margin: 0; font-size: 22px; font-weight: 300; }
.env-table { width: 100%; border-collapse: collapse; }
.env-table th { text-align: left; font-weight: 500; font-size: 13px; padding: 6px 8px; background: var(--grey-10); }
.env-table td { padding: 6px 8px; border-bottom: 1px solid var(--light-80); }
.env-table .input { width: 100%; }
.env-table td.c { text-align: center; }
.users { display: flex; flex-wrap: wrap; gap: 8px; }
.user-chip { height: 32px; display: inline-flex; align-items: center; gap: 6px; padding: 0 4px 0 12px; border-radius: var(--radius); background: var(--light); }
.user-chip .x { width: 24px; height: 24px; border: 0; background: transparent; cursor: pointer; border-radius: var(--radius); font-size: 16px; }
.user-chip.locked { padding-right: 12px; }
.add-user { display: flex; gap: 8px; }
.add-user .input { width: 180px; text-transform: uppercase; }
.save-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

@media (max-width: 700px) {
  .charts { grid-template-columns: 1fr; }
  .lay-grid { grid-template-columns: 60px minmax(0, 1fr); }
  .query { grid-template-columns: 1fr; }
  .query .row-label { padding-top: 0; }
  .bar-row { grid-template-columns: 100px minmax(0, 1fr) 100px; }
  .titlebar h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }


/* =====================================================================
   Crisp theme (0.10). Everything visual is driven by the tokens above and
   the rules below, so new screens that use the standard classes
   (panel, btn, btn-cta, chip, lay-card, notice, field-block, table.grid)
   get this look without extra work.
   ===================================================================== */
body { background: var(--bg); }
:focus-visible { outline: 2px solid var(--dark); outline-offset: 2px; }
input[type=checkbox], input[type=radio], .field input[type=checkbox], .check-line input, .radio-line input { accent-color: var(--dark); }
input.switch:checked { background: var(--dark); }

/* header and title strip */
.topbar { padding: 0 24px; min-height: 48px; }
.brand img { height: 22px; }
.brand .product { font-size: 18px; color: #fff; }
.titlebar { background: #fff; border-bottom: 1px solid var(--line); padding: 12px 24px; align-items: center; }
.title-block h1, .titlebar h1 { font-size: 24px; font-weight: 400; }
.title-input { font-size: 24px; font-weight: 400; }
.crumb { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.menu-toggle { width: 36px; height: 36px; border-color: var(--line); }
.btn { height: 34px; border-radius: var(--radius); }
.btn-cta { height: 36px; padding: 0 18px; font-size: 18.7px; } /* 14pt bold = large text: white on orange passes */
.btn-small { height: 30px; }

/* layout */
.workspace { gap: 16px; padding: 16px 24px; }
.main-col { gap: 16px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; }
.panel-head, .field-group, .row-label, .lay-section h3, .console h2, .results-head h2 {
  font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.results-head h2 { font-size: 12px; }
.row-label, .query .row-label { padding-top: 9px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.muted, .plan, .title-sub { color: var(--muted); }

/* Query / Layout / Options: plain text tabs */
.tabs { margin-bottom: 0; gap: 22px; border-bottom: 1px solid var(--line); }
.tab { height: 40px; padding: 0; border: 0; background: transparent; color: var(--muted); }
.tab[aria-selected="true"] { background: transparent; border: 0; color: var(--dark); font-weight: 500; box-shadow: inset 0 -2px 0 var(--dark); top: 1px; }

/* main / join queries: folder tabs above the query panel */
.query-nav { display: flex; align-items: flex-end; gap: 0; flex-wrap: wrap; padding: 0; border: 0; margin-bottom: -17px; position: relative; z-index: 2; }
.qnav { height: 40px; max-width: 380px; padding: 0 28px 0 14px; margin: 0 -10px 0 0; border: 0; border-radius: 0; background: #E6E8EC; color: var(--muted);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 100%, 0 100%); gap: 8px; }
.qnav:hover { background: #DCDFE5; }
.qnav.active { background: #fff; color: var(--dark); height: 42px; border: 0; padding: 0 28px 0 14px; box-shadow: inset 0 2px 0 var(--dark); z-index: 3; }
.qnav.join.active { box-shadow: inset 0 2px 0 var(--orange); }
.qnav .qtag, .qnav.join .qtag { background: none; color: inherit; padding: 0; font-size: 10px; font-weight: 700; letter-spacing: .07em; }
.qnav.join.active .qtag { color: #C42B1B; }
.qnav .qsub, .qnav.active .qsub { display: none; }
.qnav.add { clip-path: none; height: 30px; margin: 0 0 6px 18px; padding: 0 12px; border: 1px dashed var(--dark-40); border-radius: var(--radius); background: transparent; color: var(--dark); }
.qnav.add:hover { background: #fff; }
#queryPanel { border-top-left-radius: 0; }
.join-editor { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 0 0 14px; }
.qtag.join { background: none; color: #C42B1B; padding: 0; font-size: 10px; font-weight: 700; letter-spacing: .07em; }
.jlabel { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding-top: 9px; }
.join-types { gap: 0; }
.jt { border-radius: 0; border: 1px solid var(--line); margin-left: -1px; padding: 5px 12px; }
.jt:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.jt:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.jt.on { background: var(--dark); color: #fff; border: 1px solid var(--dark); padding: 5px 12px; font-weight: 500; }
.jt.on .venn-line { stroke: #fff; }
.jt.on .venn-fill { fill: #fff; opacity: .9; }
.pair .select { background: var(--light); border-color: var(--light); }
.suggest { background: var(--light-60); border: 1px solid var(--line); }

/* shelves and chips */
.shelf { border: 1px dashed var(--line); border-radius: var(--radius); }
.chip { border-radius: var(--radius); height: 30px; }
.chip.dim { background: var(--light); }
.filter { border: 1px solid var(--line); background: #fff; border-radius: var(--radius); }
.query { gap: 10px 14px; }

/* field list */
.alias, .alias.dim, .alias.mea, .alias.calc { background: transparent; color: var(--muted); padding: 0; min-width: 40px; text-align: left; }
.alias.calc { font-style: italic; }
.field { border-radius: 0; border-bottom: 1px solid var(--light-60); }
.field:hover { background: var(--light-60); }
.obj-result:hover, .obj-result.active { background: var(--light); }

/* results: a dashboard of cards on the grey page */
.results { background: transparent; border: 0; padding: 0; gap: 16px; }
.results > .empty-state, .results > .landing-empty, .results > .notice { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.results-head { padding: 0 2px; }
.kpis { gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi { background: #fff; border: 1px solid var(--line); border-top: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .k-label { font-size: 13px; color: var(--muted); }
.kpi .k-value { font-size: 30px; font-weight: 500; letter-spacing: -.01em; }
.charts { gap: 16px; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.chart { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.chart h3, .chart-head h3 { font-size: 14px; font-weight: 500; }
.bar-track { background: var(--light-60); border-radius: 2px; }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.grid th { background: #fff; color: var(--muted); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line); }
table.grid th button { color: var(--muted); }
table.grid td { border-bottom: 1px solid var(--light-60); }
table.grid tbody tr:not(.total):hover td { background: var(--light-60); }
table.grid tr.total td { background: var(--light-60); }
.notice { background: var(--light-60); border-radius: var(--radius); }
.notice.error { background: #FDECEA; }

/* Layout and Options tabs, console */
.layout { gap: 16px; }
.lay-card { background: #fff; border: 1px solid var(--line); }
.toggles { border-color: var(--line); }
.env-table th { background: var(--light-60); }
.user-chip { background: var(--light); }
.info-card { border-top: 2px solid var(--dark); border-radius: var(--radius); }
.save-dialog { border-radius: var(--radius); }
.login-card { border-radius: var(--radius); }
.btn-login { border-radius: var(--radius); font-size: 18.7px; }
.rm-search { border-radius: var(--radius); }

/* ---------- subtotals and pivots ---------- */
.st-wrap { display: flex; flex-direction: column; gap: 10px; }
.st-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.st-toggle { width: 22px; height: 22px; border: 0; background: transparent; color: var(--muted); cursor: pointer; margin-right: 4px; padding: 0; font-size: 12px; }
.st-toggle:hover { color: var(--dark); }
table.grid tr.st-sub td { background: var(--light-60); font-weight: 500; }
table.grid tr.st-sub.lvl-1 td { background: #FAFAFB; }
.st-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.st-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 10px 12px; }
.st-card-head .st-name { font-weight: 500; }
.st-card-head .spacer { flex: 1; }
.st-val { display: inline-flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.st-val .muted { font-size: 11px; }
.st-total { background: var(--light-60); }
.table-wrap.flat { border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.pivots { display: flex; flex-direction: column; gap: 16px; }
.pivot .chart-head { gap: 12px; }
.check-line.small { font-size: 13px; color: var(--muted); }
table.pivot-grid th.grp, table.pivot-grid td.grp { border-left: 1px solid var(--line); }
table.pivot-grid th.tot { background: var(--light-60); }
table.pivot-grid .sticky { position: sticky; left: 0; background: #fff; z-index: 1; }
table.pivot-grid tr.st-sub .sticky, table.pivot-grid tr.total .sticky { background: var(--light-60); }
.pv-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; }
.pv-label { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.pv-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; align-items: center; }
.pv-checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.select.small { height: 30px; font-size: 13px; }
.muted.pad { padding: 14px 16px; margin: 0; }
@media (max-width: 700px) { .pv-row { grid-template-columns: 1fr; } }

/* charts keep their height on wide screens */
svg.mapchart { max-height: 460px; }
body.tab-layout .fields-panel, body.tab-options .fields-panel { display: none; }

/* ---------- designer frame (0.12): numbered tabs on one white frame ---------- */
.workspace { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
.designer-frame { display: flex; flex-direction: column; }
.frame-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.frame-tabs .tab { height: auto; padding: 11px 20px; font-size: 15px; color: var(--muted); background: transparent; border: 1px solid transparent; border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0; box-shadow: none; display: inline-flex; align-items: center; gap: 8px; top: 0; }
.frame-tabs .tab:hover { color: var(--dark); background: #fff; }
.frame-tabs .tab[aria-selected="true"] { background: #fff; color: var(--dark); font-weight: 500; border-color: var(--line); margin-bottom: -1px; padding-bottom: 12px;
  box-shadow: inset 0 3px 0 var(--orange); }
.tab-num { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--dark-40); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; }
.tab[aria-selected="true"] .tab-num { background: var(--dark); border-color: var(--dark); color: #fff; }
.tab-sum { font-size: 12px; font-weight: 400; color: var(--muted); }
.tab-sum:not(:empty)::before { content: "· "; }
.frame-body { background: #fff; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); padding: 16px; display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.frame-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.frame-body .fields-panel { border: 1px solid var(--line); }
.frame-main #layoutPanel, .frame-main #optionsPanel { border: 0; padding: 0; }
.frame-main .query-nav { margin-bottom: -1px; }
.frame-main #queryPanel { border-radius: 0 var(--radius) var(--radius) var(--radius); }
@media (max-width: 700px) { .frame-tabs .tab { padding: 9px 12px; } .tab-sum { display: none; } }

/* ---------- 0.13: report filters, comparison rules, summarize, canvas ---------- */
.spacer { flex: 1; }
.link { background: none; border: 0; padding: 0; color: var(--dark); text-decoration: underline; cursor: pointer; font: inherit; font-size: 13px; }
.rf-setup .tag { font-size: 11px; color: var(--dark-80); background: var(--light); border-radius: var(--radius); padding: 1px 6px; white-space: nowrap; }

/* filter bar above the report */
.rf-wrap { display: flex; flex-direction: column; gap: 6px; }
.rf-bar { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 12px; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; }
.rf-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; position: relative; }
.rf-label { font-size: 12px; color: var(--muted); }
.rf-field .input, .rf-field .select { height: 34px; }
.rf-field .input.set, .rf-ctl.set { border-color: var(--dark); box-shadow: inset 0 -2px 0 var(--orange); }
.rf-ctl { height: 34px; min-width: 150px; max-width: 260px; border: 1px solid var(--dark-40); border-radius: var(--radius); background: #fff; padding: 0 10px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.rf-ctl-text { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rf-pick { position: relative; }
.rf-pop { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; width: 320px; max-width: 90vw; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(30, 39, 74, .16); display: flex; flex-direction: column; }
.rf-pop-head { padding: 8px; }
.rf-pop-head .input { width: 100%; }
.rf-pop-actions { display: flex; gap: 12px; padding: 0 10px 6px; align-items: center; }
.rf-opts { max-height: 280px; overflow-y: auto; border-top: 1px solid var(--light-80); }
.rf-opt { display: grid; grid-template-columns: 18px minmax(44px, auto) 1fr; gap: 8px; align-items: center; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.rf-opt:hover { background: var(--light-60); }
.rf-code { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.rf-pop-foot { font-size: 12px; padding: 6px 10px; border-top: 1px solid var(--light-80); }
.rf-range { display: flex; align-items: center; gap: 4px; }
.rf-range .input[type=date] { width: 150px; }
.rf-num { width: 96px; }
.rf-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.rf-status { font-size: 12px; max-width: 260px; }
.rf-summary { font-size: 13px; padding: 0 2px; }
.seg { display: inline-flex; border: 1px solid var(--dark); border-radius: var(--radius); overflow: hidden; height: 34px; }
.seg button { border: 0; background: #fff; padding: 0 12px; font-size: 13px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--dark); }
.seg button[aria-pressed=true] { background: var(--dark); color: #fff; }

/* side panel when there are many filters */
.rf-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.rf-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.rf-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 8px; }
.rf-panel .rf-ctl { max-width: none; width: 100%; }
.rf-panel .rf-range { flex-wrap: wrap; }
.rf-panel .rf-actions { margin-left: 0; flex-wrap: wrap; }
.rf-panel-head { display: flex; align-items: center; justify-content: space-between; }
.rf-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.rf-closed { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rf-closed .chip { background: #fff; border: 1px solid var(--line); color: var(--dark); font-size: 13px; padding: 4px 10px; border-radius: var(--radius); }
@media (max-width: 900px) { .rf-layout { grid-template-columns: 1fr; } .rf-panel { position: static; } }

/* Options tab: report filter setup and comparison rules */
.rf-setup tr.grp td { background: var(--light-60); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.rf-setup tr.off td { color: var(--muted); }
.rf-setup .input { height: 30px; min-width: 180px; }
.cmp-list { display: flex; flex-direction: column; gap: 6px; }
.cmp-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; background: #fff; }
.cmp-editor { border-color: var(--dark); gap: 12px; }
.cmp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
@media (max-width: 800px) { .cmp-grid { grid-template-columns: 1fr; } }

/* summarize by visible columns */
.table-block { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.sum-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; padding: 8px 12px; background: var(--light-60);
  border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
.sum-bar + .table-wrap, .sum-bar + .notice { border-top-left-radius: 0; border-top-right-radius: 0; }
.sum-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); flex: none; }

/* ---------- 0.14: layout grid ---------- */
.small { font-size: 12px; }
.dg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 10px; }
.dg-cnt { display: inline-flex; align-items: center; border: 1px solid var(--dark-40); border-radius: var(--radius); height: 30px; background: #fff; }
.dg-cnt button { width: 28px; height: 28px; border: 0; background: #fff; cursor: pointer; font-size: 15px; }
.dg-cnt button:disabled { color: var(--dark-40); cursor: default; }
.dg-cnt span { padding: 0 10px; font-size: 13px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); line-height: 28px; }
.dg-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .dg-wrap { grid-template-columns: 1fr; } }
.dg-edit { display: grid; position: relative; }
.dg-colh, .dg-rowh { display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 12px; color: var(--muted); }
.dg-rowh { flex-direction: column; }
.dg-colh .x, .dg-rowh .x, .chip-out .x { border: 0; background: none; width: 20px; height: 20px; cursor: pointer; color: var(--muted); padding: 0; font-size: 14px; }
.dg-vh, .dg-hh { display: flex; align-items: center; justify-content: center; z-index: 1; touch-action: none; }
.dg-vh { cursor: col-resize; } .dg-hh { cursor: row-resize; }
.dg-vh i { width: 2px; height: 100%; background: var(--dark-20); position: relative; }
.dg-hh i { height: 2px; width: 100%; background: var(--dark-20); position: relative; }
.dg-vh i::after, .dg-hh i::after { content: ""; position: absolute; background: #fff; border: 1px solid var(--dark-40); border-radius: 3px; }
.dg-vh i::after { top: 50%; left: -4px; width: 8px; height: 28px; margin-top: -14px; }
.dg-hh i::after { left: 50%; top: -4px; height: 8px; width: 28px; margin-left: -14px; }
.dg-vh:hover i, .dg-hh:hover i, .dg-vh:focus-visible i, .dg-hh:focus-visible i { background: var(--orange); }
.dg-vh:hover i::after, .dg-hh:hover i::after { border-color: var(--orange); }
.dg-tip { position: absolute; z-index: 20; background: var(--dark); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: var(--radius); white-space: nowrap; pointer-events: none; }
.dg-empty { position: relative; z-index: 2; border: 1px dashed var(--dark-40); border-radius: var(--radius); background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-width: 0; }
.dg-empty.sel, .dg-empty.drop-in, .dg-etile.drop-in { border: 2px solid var(--orange); }
.dg-empty.sel, .dg-etile.menu-open { z-index: 30; }   /* its menu must cover the neighbouring tiles */
.dg-plus { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--dark); background: #fff; font-size: 22px; font-weight: 300; cursor: pointer; line-height: 1; }
.dg-plus:hover, .dg-plus[aria-expanded=true] { background: var(--dark); color: #fff; }
.dg-menu { position: absolute; top: calc(50% + 24px); left: 50%; transform: translateX(-50%); z-index: 40; width: 330px; max-width: 80vw; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 8px 22px rgba(30, 39, 74, .16); padding: 8px 0; display: flex; flex-direction: column; }
.dg-menu .rf-title { padding: 4px 14px 6px; }
.dg-mi { display: grid; grid-template-columns: 32px 1fr; gap: 10px; align-items: center; padding: 7px 14px; border: 0; background: #fff; text-align: left; cursor: pointer; font: inherit; }
.dg-mi:hover:not(:disabled) { background: var(--light-60); }
.dg-mi:disabled { cursor: not-allowed; opacity: .55; }
.dg-mi b { font-weight: 500; display: block; } .dg-mi small { display: block; font-size: 12px; color: var(--muted); }
.dg-mi.small { padding: 5px 14px; font-size: 13px; }
.dg-ic { width: 32px; height: 32px; border-radius: var(--radius); background: var(--light); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.dg-types { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 14px 8px 56px; }
.dg-types button { height: 26px; padding: 0 8px; border: 1px solid var(--dark-40); border-radius: var(--radius); background: #fff; font-size: 12px; cursor: pointer; }
.dg-types button:hover { border-color: var(--dark); background: var(--light-60); }
.dg-etile { position: relative; z-index: 2; min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; cursor: pointer; }
.dg-etile.sel { border: 2px solid var(--orange); }
.dg-etile.k-kpi { box-shadow: inset 0 3px 0 var(--orange); }
.dg-thead { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 8px; font-size: 13px; font-weight: 500; cursor: grab; border-bottom: 1px solid var(--light-80); }
.dg-ttl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-thead .tag { font-size: 11px; background: var(--light); border-radius: var(--radius); padding: 1px 6px; font-weight: 400; }
.dg-tbody { padding: 6px 10px; font-size: 12px; overflow: hidden; }
.dg-tmenu { position: absolute; top: 34px; right: 4px; z-index: 40; width: 250px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 22px rgba(30, 39, 74, .16); padding: 4px 0; }
.dg-tmenu button { display: block; width: 100%; text-align: left; border: 0; background: #fff; padding: 7px 14px; font: inherit; font-size: 13px; cursor: pointer; }
.dg-tmenu button:hover:not(:disabled) { background: var(--light-60); }
.dg-tmenu button:disabled { color: var(--dark-40); cursor: default; }
.dg-tmenu hr { border: 0; border-top: 1px solid var(--light-80); margin: 4px 0; }
.dg-side, .dg-settings { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.dg-side .lay-grid { grid-template-columns: 90px minmax(0, 1fr); }
.dg-tinfo .lay-actions { flex-wrap: wrap; }
.dg-tray { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-out { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--dark); border-radius: var(--radius); padding: 3px 4px 3px 8px; font-size: 12px; max-width: 100%; }
.kpi-target { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rt-bar { display: flex; flex-wrap: wrap; gap: 4px; }
.rt-btn { min-width: 30px; height: 28px; border: 1px solid var(--dark-40); border-radius: var(--radius); background: #fff; cursor: pointer; font-size: 13px; font-weight: 600; }
.rt-btn:hover { border-color: var(--dark); }
.rt-edit { min-height: 140px; max-height: 360px; overflow: auto; border: 1px solid var(--dark-40); border-radius: var(--radius); padding: 8px 10px; background: #fff; }
.rt-edit:focus { outline: 2px solid var(--dark); outline-offset: 1px; }
.rt-html { font-family: var(--mono); font-size: 12px; }

/* run view */
.dg-run { display: grid; gap: 14px; }
.dg-cell { min-width: 0; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.dg-cell > * { flex: 1 1 auto; min-height: 0; }
.dg-cell > .chart, .dg-cell > .text-tile { overflow: auto; }
.dg-cell .table-block, .dg-cell .st-wrap { display: flex; flex-direction: column; min-height: 0; }
.dg-cell .table-wrap { max-height: none; flex: 1 1 auto; min-height: 0; overflow: auto; }
.dg-cell .table-wrap thead th { position: sticky; top: 0; z-index: 1; background: #fff; }
.kpi-tile { display: flex; flex-direction: column; gap: 4px; }
.kpi-tile .k-sub { font-size: 12px; color: var(--muted); }
.spark { width: 100%; height: 40px; display: block; margin-top: 4px; }
.bullet { height: 6px; background: var(--grey-10); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bullet .fill { display: block; height: 100%; background: var(--orange); }
.bullet .fill.met { background: var(--dark); }
.donut-total { font-size: 15px; font-weight: 500; fill: var(--dark); }
.text-tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; min-width: 0; }
.text-tile.rt > :first-child { margin-top: 0; }
.text-tile.rt h1, .text-tile.rt h2, .text-tile.rt h3, .text-tile.rt h4 { font-weight: 500; margin: .6em 0 .3em; }
.text-tile.rt h2 { font-size: 20px; } .text-tile.rt h3 { font-size: 16px; }
.text-tile.rt p { margin: .4em 0; } .text-tile.rt table { border-collapse: collapse; } .text-tile.rt td, .text-tile.rt th { border: 1px solid var(--line); padding: 4px 8px; }
.text-tile.web { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; }
.text-tile.web iframe { flex: 1; width: 100%; min-height: 160px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.web-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.web-note { font-size: 11px; margin: 0; }
@media (max-width: 900px) {
  .dg-run { grid-template-columns: 1fr 1fr !important; grid-template-rows: none !important; }
  .dg-cell { grid-column: span 2 !important; grid-row: auto !important; height: var(--h); }
  .dg-cell.k-kpi { grid-column: span 1 !important; height: auto; }
  .dg-cell.k-chart, .dg-cell.k-pivot, .dg-cell.k-text { height: max(var(--h), 300px); }
}

/* canvas: rows of slots in the report */
.cv-row { display: grid; gap: 16px; align-items: stretch; }
.cv-slot { min-width: 0; display: flex; flex-direction: column; }
.cv-slot > .chart, .cv-slot > .table-block, .cv-slot > .st-wrap, .cv-slot > .table-wrap { flex: 1; }
.cv-slot .kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
@media (max-width: 900px) { .cv-row.multi { grid-template-columns: 1fr !important; } }

/* canvas: arrangement editor on the Layout tab */
.cv-presets { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0; }
.cv-preset { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer; width: 132px; }
.cv-preset:hover { border-color: var(--dark); }
.cv-pname { font-size: 12px; text-align: left; }
.cv-thumb { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; width: 112px; }
.cv-thumb span { height: 12px; border-radius: 2px; }
.cv-thumb .k { height: 6px; background: var(--dark-20); }
.cv-thumb .c { background: var(--dark); height: 18px; }
.cv-thumb .t { height: 16px; background: repeating-linear-gradient(var(--light) 0 3px, #fff 3px 5px); border: 1px solid var(--dark-20); }
.cv-thumb .w4 { grid-column: span 4; } .cv-thumb .w3 { grid-column: span 3; } .cv-thumb .w2 { grid-column: span 2; } .cv-thumb .w1 { grid-column: span 1; }
.cv-thumb-three { grid-template-columns: repeat(3, 1fr); } .cv-thumb-three .w4 { grid-column: span 3; } .cv-thumb .w1x { grid-column: span 1; }
.cv-bands { display: flex; flex-direction: column; gap: 8px; }
.cv-band { border: 1px solid var(--line); border-radius: var(--radius); background: var(--light-40); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.cv-band.drop-in { border-color: var(--orange); }
.cv-band-head { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.cv-slots { display: flex; gap: 8px; }
.cv-blk { min-width: 0; background: #fff; border: 1px solid var(--dark-40); border-radius: var(--radius); padding: 6px 8px; display: flex; align-items: center; gap: 6px; cursor: grab; }
.cv-blk.drop-before { box-shadow: inset 3px 0 0 var(--orange); }
.cv-blabel { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.cv-bbtns { display: flex; align-items: center; gap: 0; flex: none; }
.cv-bbtns .icon-btn { width: 26px; height: 26px; }
.cv-more summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-top: 6px; }
@media (max-width: 700px) { .cv-slots { flex-direction: column; } }
