/* kpiee — view-specific styles (shared contract for all view modules) */

/* ===== Dashboard ===== */
.hero { position: relative; overflow: hidden; border-radius: var(--r-lg); padding: 26px 30px; color: #fff;
  background: radial-gradient(120% 160% at 100% 0%, #8f7dff 0%, #6d5ef8 42%, #4934d6 100%); box-shadow: var(--sh-brand); }
.hero::after { content: ""; position: absolute; right: -40px; top: -60px; width: 320px; height: 320px; border-radius: 50%; background: rgba(255,255,255,.12); }
.hero::before { content: ""; position: absolute; right: 120px; bottom: -90px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,.08); }
.hero-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; opacity: .9; text-transform: uppercase; }
.hero-title { font-size: 25px; font-weight: 800; margin: 8px 0 4px; line-height: 1.35; position: relative; }
.hero-sub { font-size: 13.5px; opacity: .92; position: relative; }
.hero-metrics { display: flex; gap: 30px; margin-top: 18px; position: relative; flex-wrap: wrap; }
.hero-metric .hm-label { font-size: 11.5px; opacity: .85; }
.hero-metric .hm-value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hero-metric .hm-sub { font-size: 11.5px; opacity: .9; }

.alert-feed { display: flex; flex-direction: column; gap: 10px; }
.alert-item { display: flex; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); align-items: flex-start; transition: .15s; cursor: pointer; }
.alert-item:hover { background: var(--surface); box-shadow: var(--sh-1); transform: translateX(2px); }
.alert-mark { width: 36px; height: 36px; border-radius: 10px; flex: 0 0 36px; display: grid; place-items: center; font-size: 16px; }
.alert-mark.good { background: var(--pos-soft); } .alert-mark.bad { background: var(--neg-soft); } .alert-mark.warn { background: var(--warn-soft); }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-size: 13px; font-weight: 700; }
.alert-detail { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.alert-meta { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.slack-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; color: #4a154b; background: #f3e6f5; padding: 2px 7px; border-radius: 6px; }

.health-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.health-row:last-child { border: none; }
.health-name { width: 92px; flex: 0 0 92px; font-size: 13px; font-weight: 700; }
.health-bar-wrap { flex: 1; }

/* ===== KPI matrix view ===== */
.matrix-scroll { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: var(--r-sm); }
.kpi-legend { display: flex; gap: 16px; align-items: center; font-size: 12px; color: var(--ink-3); }
.kpi-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 5px; vertical-align: -1px; }

/* ===== Analysis (pivot / org) ===== */
.axis-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.axis-tab { border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; border-radius: 99px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.axis-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.drill-crumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); flex-wrap: wrap; }
.drill-crumb b { color: var(--ink); }
.drill-crumb .crumb { cursor: pointer; color: var(--brand-600); font-weight: 700; }
.org-tree { font-size: 13px; }
.org-node { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.org-node:hover { background: var(--surface-2); }
.org-toggle { width: 18px; flex: 0 0 18px; text-align: center; color: var(--ink-3); font-size: 11px; }
.org-name { font-weight: 600; }
.org-bar { height: 8px; border-radius: 99px; background: var(--brand); }
.org-val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; }
.org-children { margin-left: 18px; border-left: 1px dashed var(--line); padding-left: 8px; }
.lvl-badge { font-size: 10px; font-weight: 700; color: var(--ink-4); background: var(--surface-3); padding: 1px 6px; border-radius: 5px; }

/* ===== Allocation ===== */
.alloc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px){ .alloc-grid { grid-template-columns: 1fr; } }
.basis-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.basis-opt { flex: 1; min-width: 140px; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; transition: .15s; }
.basis-opt:hover { border-color: var(--line-2); }
.basis-opt.active { border-color: var(--brand); background: var(--brand-soft); }
.basis-opt .bo-name { font-weight: 700; font-size: 13px; }
.basis-opt .bo-desc { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.alloc-flow { display: flex; align-items: center; gap: 14px; }
.alloc-node { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface-2); flex: 1; text-align: center; }
.alloc-node .an-label { font-size: 12px; color: var(--ink-3); }
.alloc-node .an-value { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.alloc-arrow { color: var(--ink-4); font-size: 22px; }
.alloc-target { display: flex; flex-direction: column; gap: 10px; }
.alloc-target-row { display: flex; align-items: center; gap: 12px; }
.alloc-target-row .atr-name { width: 90px; flex: 0 0 90px; font-weight: 700; font-size: 13px; }
.alloc-target-row .atr-bar { flex: 1; height: 26px; background: var(--surface-3); border-radius: 8px; overflow: hidden; position: relative; }
.alloc-target-row .atr-fill { height: 100%; background: var(--brand-grad); border-radius: 8px; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; color: #fff; font-weight: 800; font-size: 12px; transition: width .6s var(--ease-out); }

/* ===== Competitor ===== */
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px){ .metric-grid { grid-template-columns: 1fr; } }
.insight-callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--brand-soft); border: 1px dashed var(--brand); color: var(--brand-700); font-size: 13px; font-weight: 600; }
.insight-callout .ic-ic { font-size: 16px; }

/* ===== Assistant ===== */
.assistant-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 16px; height: calc(100vh - var(--topbar-h) - 86px); }
@media (max-width: 1100px){ .assistant-wrap { grid-template-columns: 1fr; height: auto; } }
.chat { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--sh-1); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.chat-head .ch-title { font-weight: 800; }
.chat-head .ch-status { margin-left: auto; font-size: 11.5px; color: var(--pos); font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.chat-msg { display: flex; gap: 10px; max-width: 86%; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-ava { width: 30px; height: 30px; border-radius: 9px; flex: 0 0 30px; display: grid; place-items: center; background: var(--surface-3); }
.chat-msg.ai .chat-ava { background: var(--brand-soft); }
.bubble { padding: 11px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.6; }
.chat-msg.ai .bubble { background: var(--surface-2); border: 1px solid var(--line); border-top-left-radius: 4px; }
.chat-msg.user .bubble { background: var(--brand-grad); color: #fff; border-top-right-radius: 4px; }
.bubble .ans-num { font-weight: 800; color: var(--brand-600); }
.chat-msg.user .bubble .ans-num { color: #fff; }
.bubble-chart { margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.bubble-table { margin-top: 8px; font-size: 12px; }
.composer { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--line); background: var(--surface); }
.composer input { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 14px; outline: none; background: var(--surface-2); }
.composer input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: var(--surface); }
.composer .send { border: none; background: var(--brand-grad); color: #fff; border-radius: 12px; width: 46px; display: grid; place-items: center; font-size: 18px; box-shadow: var(--sh-brand); }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; }
.suggest-chip { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 99px; cursor: pointer; }
.suggest-chip:hover { border-color: var(--brand); color: var(--brand-600); background: var(--brand-soft); }
.notif-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; box-shadow: var(--sh-1); overflow-y: auto; }
.notif-card { display: flex; gap: 10px; padding: 11px; border-radius: 11px; border: 1px solid var(--line); margin-bottom: 10px; }
.notif-card .nc-bar { width: 4px; border-radius: 3px; flex: 0 0 4px; }
.typing { display: inline-flex; gap: 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); animation: kpType 1s infinite; }
.typing span:nth-child(2){ animation-delay: .15s; } .typing span:nth-child(3){ animation-delay: .3s; }
@keyframes kpType { 0%,60%,100%{ transform: translateY(0); opacity: .4 } 30%{ transform: translateY(-4px); opacity: 1 } }

/* ===== Connect (data integration) ===== */
.pipeline { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; position: relative; }
@media (max-width: 900px){ .pipeline { grid-template-columns: 1fr 1fr; } }
.stage { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--surface); position: relative; box-shadow: var(--sh-1); }
.stage-no { font-size: 11px; font-weight: 800; color: var(--brand); }
.stage-name { font-size: 15px; font-weight: 800; margin: 4px 0; }
.stage-desc { font-size: 12px; color: var(--ink-3); }
.stage-auto { margin-top: 10px; display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: var(--pos); background: var(--pos-soft); padding: 3px 8px; border-radius: 7px; }
.stage::after { content: "→"; position: absolute; right: -10px; top: 50%; transform: translateY(-50%); color: var(--ink-4); font-weight: 800; z-index: 2; }
.stage:last-child::after { display: none; }
.source-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 1100px){ .source-grid { grid-template-columns: repeat(2, 1fr); } }
.source-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; box-shadow: var(--sh-1); transition: .15s; }
.source-card:hover { box-shadow: var(--sh-2); transform: translateY(-2px); }
.source-top { display: flex; align-items: center; gap: 10px; }
.source-ic { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-3); display: grid; place-items: center; font-size: 19px; }
.source-name { font-weight: 700; font-size: 14px; }
.source-tool { font-size: 11.5px; color: var(--ink-3); }
.source-stat { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; }
.sync-badge { display: inline-flex; align-items: center; gap: 5px; color: var(--pos); font-weight: 700; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pos); box-shadow: 0 0 0 3px var(--pos-soft); animation: kpPulse 2s infinite; }
@keyframes kpPulse { 0%,100%{ opacity: 1 } 50%{ opacity: .4 } }
.group-label { font-size: 12px; font-weight: 800; color: var(--ink-3); margin: 6px 0; }

/* ===== PL report ===== */
.pl-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.pl-toolbar .kp-select-wrap { min-width: 0; }
.pl-toolbar .kp-select { min-width: 132px; background-color: var(--surface); }
.pl-filter { position: relative; }
.pl-filter-trigger { display: inline-flex; align-items: center; gap: 7px; }
.pl-filter-popover { position: absolute; right: 0; top: calc(100% + 8px); z-index: 45; width: 272px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--sh-2); opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .16s var(--ease), transform .16s var(--ease), visibility .16s; }
.pl-filter-popover.open, .pl-filter-popover.show, .pl-filter.open .pl-filter-popover { opacity: 1; visibility: visible; transform: none; }
.pl-filter-title { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; font-size: 13px; font-weight: 800; }
.pl-filter-note { margin: -3px 0 10px; color: var(--ink-3); font-size: 12px; line-height: 1.55; }
.pl-check { display: flex; align-items: center; gap: 8px; padding: 7px 2px; color: var(--ink-2); font-size: 12.5px; cursor: pointer; }
.pl-check input { accent-color: var(--brand); }
.pl-filter-list { display: flex; flex-direction: column; gap: 7px; }
.pl-filter-option { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; color: var(--ink-2); font-size: 12.5px; cursor: pointer; }
.pl-filter-option:hover { background: var(--surface-2); color: var(--ink); }
.pl-filter-option input { accent-color: var(--brand); }
.pl-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.pl-table { min-width: 1040px; }
.pl-table .pl-group-row td, .pl-table tr.pl-group td { background: var(--surface-3); color: var(--ink); font-weight: 800; }
.pl-table .pl-child-row td:first-child, .pl-table tr.pl-child td:first-child { padding-left: 34px; }
.pl-table .pl-hidden, .pl-table tr.pl-hidden, .pl-table tr.is-collapsed { display: none; }
.pl-group-toggle { display: inline-grid; place-items: center; width: 20px; height: 20px; margin: -2px 6px -2px -2px; padding: 0; border: 0; border-radius: 6px; color: var(--ink-3); background: transparent; font-size: 11px; line-height: 1; vertical-align: middle; cursor: pointer; }
.pl-group-toggle:hover { background: var(--brand-soft); color: var(--brand-600); }
.pl-group-toggle[aria-expanded="false"] { transform: rotate(-90deg); }
.pl-cell-selected, .pl-table td.pl-cell-selected, .pl-table th.pl-cell-selected { position: relative; z-index: 3; color: var(--ink); background: var(--brand-soft) !important; box-shadow: inset 0 0 0 2px var(--brand); }
.pl-table td[data-pl-cell] { cursor: cell; }
.pl-table td[data-pl-cell]:focus { outline: none; }
.pl-memo, .pl-table .pl-memo { display: inline-block; min-width: 150px; max-width: 260px; overflow: hidden; color: var(--ink-3); font-size: 12px; text-overflow: ellipsis; }

/* ===== Account hierarchy master ===== */
.hierarchy-page-head { align-items: center; }
.hierarchy-breadcrumb, .hierarchy-crumb { display: flex; align-items: center; gap: 7px; color: var(--ink-3); font-size: 13px; }
.hierarchy-breadcrumb b, .hierarchy-crumb b { color: var(--ink); font-weight: 800; }
.hierarchy-breadcrumb .current, .hierarchy-crumb .current { color: var(--brand-600); font-weight: 700; }
.hierarchy-actions { display: flex; align-items: center; gap: 8px; }
.hierarchy-wrap { position: relative; overflow: auto; max-height: calc(100vh - 220px); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.hierarchy-table { width: max-content; min-width: 1180px; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.hierarchy-table th, .hierarchy-table td { min-width: 128px; height: 43px; padding: 9px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.hierarchy-table th { position: sticky; top: 0; z-index: 4; color: var(--ink-3); background: var(--surface); font-size: 11.5px; font-weight: 800; text-align: left; }
.hierarchy-table th:first-child, .hierarchy-table td:first-child, .hierarchy-table .hierarchy-code { position: sticky; left: 0; z-index: 2; min-width: 104px; background: var(--surface); font-family: var(--num); color: var(--ink-3); font-size: 12px; font-weight: 700; }
.hierarchy-table th:first-child, .hierarchy-table thead .hierarchy-code { z-index: 6; }
.hierarchy-table tbody tr:hover td { background: var(--surface-2); }
.hierarchy-table tbody tr:hover td:first-child { background: var(--surface-2); }
.hierarchy-table .hierarchy-row-no { width: 48px; min-width: 48px; color: var(--ink-4); text-align: right; }
.hierarchy-table td[data-hierarchy-cell] { cursor: cell; }
.hierarchy-table tr.hierarchy-row-selected td, .hierarchy-table tr.hierarchy-row-active td { background: rgba(109,94,248,.055); }
.hierarchy-table tr.hierarchy-row-selected td:first-child, .hierarchy-table tr.hierarchy-row-active td:first-child { background: var(--brand-soft); color: var(--brand-600); }
.hierarchy-table .hierarchy-col-selected, .hierarchy-table .hierarchy-col-active { background: rgba(109,94,248,.075); }
.hierarchy-table th.hierarchy-col-selected, .hierarchy-table th.hierarchy-col-active { color: var(--brand-600); background: var(--brand-soft); }
.hierarchy-table td.hierarchy-cell-selected, .hierarchy-table td.hierarchy-cell-active { position: relative; z-index: 3; color: var(--ink); background: var(--brand-soft) !important; box-shadow: inset 0 0 0 2px var(--brand); }
.hierarchy-table .hierarchy-depth { color: var(--ink); font-weight: 700; }
.hierarchy-table .hierarchy-depth-1 { color: var(--brand-700); font-weight: 800; }
.hierarchy-table .hierarchy-depth-2 { font-weight: 750; }
.hierarchy-toast { position: fixed; right: 24px; bottom: 24px; z-index: 2000; display: flex; align-items: center; gap: 8px; padding: 11px 15px; border: 1px solid rgba(23,184,144,.28); border-radius: 11px; color: var(--pos); background: var(--surface); box-shadow: var(--sh-3); font-size: 13px; font-weight: 700; opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity .22s var(--ease-out), transform .22s var(--ease-out); }
.hierarchy-toast.show, .hierarchy-toast.open, .hierarchy-toast.is-visible { opacity: 1; transform: none; }

/* ===== Report builder ===== */
.rb-page-head { align-items: center; }
.rb-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.rb-sub-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: -8px 0 14px; }
.rb-grid { display: grid; grid-template-columns: minmax(270px, .9fr) minmax(480px, 1.45fr); grid-template-areas: "vertical metrics" "horizontal metrics"; align-items: start; gap: 16px; }
.rb-panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--sh-1); }
.rb-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 17px 12px; border-bottom: 1px solid var(--line); }
.rb-panel-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 800; }
.rb-panel-title .rb-panel-no { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; color: var(--brand-600); background: var(--brand-soft); font-size: 11px; }
.rb-panel-body { padding: 15px 17px 17px; }
.rb-vertical, .rb-axis-y, .rb-y-axis { grid-area: vertical; }
.rb-horizontal, .rb-axis-x, .rb-x-axis { grid-area: horizontal; }
.rb-metrics, .rb-metric-panel { grid-area: metrics; }
.rb-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px; border-radius: 10px; background: var(--surface-3); }
.rb-tab { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 31px; padding: 5px 10px; border: 0; border-radius: 7px; color: var(--ink-3); background: transparent; font-size: 12px; font-weight: 700; }
.rb-tab:hover { color: var(--ink); background: rgba(255,255,255,.45); }
.rb-tab.active, .rb-tab.is-active { color: var(--brand-600); background: var(--surface); box-shadow: var(--sh-1); }
.rb-tab.active::before, .rb-tab.is-active::before { content: "✓"; font-size: 11px; }
.rb-form-stack { display: flex; flex-direction: column; gap: 12px; }
.rb-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.rb-field label, .rb-field-label { color: var(--ink-3); font-size: 11px; font-weight: 700; }
.rb-field .kp-select, .rb-field select, .rb-field input, .rb-metric-row select, .rb-metric-row input { width: 100%; min-width: 0; height: 36px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background-color: var(--surface); font: inherit; font-size: 12.5px; }
.rb-field input, .rb-metric-row input { padding: 7px 9px; }
.rb-field input:focus, .rb-metric-row select:focus, .rb-metric-row input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.rb-metric-list { display: flex; flex-direction: column; gap: 9px; }
.rb-metric-row { display: grid; grid-template-columns: 16px max-content minmax(105px, 1fr) minmax(105px, 1fr) minmax(105px, 1fr) 30px; align-items: center; gap: 7px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.rb-metric-row:hover { border-color: var(--line-2); box-shadow: var(--sh-1); }
.rb-metric-row.rb-metric-calculation, .rb-metric-row.rb-metric-calc { grid-template-columns: 16px max-content minmax(160px, 1.2fr) minmax(130px, 1fr) 30px; }
.rb-metric-handle { color: var(--ink-4); font-size: 14px; line-height: .75; letter-spacing: -1px; cursor: grab; user-select: none; }
.rb-metric-type, .rb-metric-tag { display: inline-flex; align-items: center; justify-content: center; min-height: 23px; padding: 3px 7px; border-radius: 6px; font-size: 10.5px; font-weight: 800; white-space: nowrap; }
.rb-metric-type.data, .rb-metric-tag.data, .rb-metric-type.file, .rb-metric-tag.file { color: var(--info); background: var(--info-soft); }
.rb-metric-type.calc, .rb-metric-tag.calc, .rb-metric-type.calculation, .rb-metric-tag.calculation { color: var(--brand-600); background: var(--brand-soft); }
.rb-metric-type.period, .rb-metric-tag.period, .rb-metric-type.previous, .rb-metric-tag.previous { color: #7651d4; background: #eee8ff; }
:root[data-theme="dark"] .rb-metric-type.period, :root[data-theme="dark"] .rb-metric-tag.period, :root[data-theme="dark"] .rb-metric-type.previous, :root[data-theme="dark"] .rb-metric-tag.previous { background: #2d2447; }
.rb-metric-formula { min-width: 0; overflow: hidden; padding: 8px 10px; border: 1px dashed var(--line-2); border-radius: 8px; color: var(--ink-2); background: var(--surface); font-family: var(--num); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.rb-metric-delete { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 7px; color: var(--ink-4); background: transparent; font-size: 15px; }
.rb-metric-delete:hover { color: var(--neg); background: var(--neg-soft); }
.rb-add-metric { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; border: 1px dashed var(--brand); border-radius: 8px; padding: 7px 11px; color: var(--brand-600); background: var(--brand-soft); font-size: 12.5px; font-weight: 800; }
.rb-add-metric:hover { filter: brightness(.98); }
.rb-preview { margin-top: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--sh-1); }
.rb-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 17px; border-bottom: 1px solid var(--line); }
.rb-preview-title { margin: 0; font-size: 14px; font-weight: 800; }
.rb-preview-note { color: var(--ink-3); font-size: 12px; }
.rb-preview .kp-table-wrap { border: 0; border-radius: 0; }
.rb-preview .kp-table { min-width: 620px; }
.rb-preview-empty { display: grid; min-height: 124px; place-items: center; padding: 22px; color: var(--ink-3); font-size: 13px; text-align: center; }

@media (max-width: 980px) {
  .rb-grid { grid-template-columns: 1fr; grid-template-areas: "vertical" "horizontal" "metrics"; }
}
@media (max-width: 720px) {
  .pl-toolbar { justify-content: flex-start; }
  .pl-filter-popover { right: auto; left: 0; max-width: calc(100vw - 32px); }
  .hierarchy-wrap { max-height: none; }
  .rb-page-head, .rb-actions, .rb-sub-actions { align-items: stretch; }
  .rb-actions, .rb-sub-actions { justify-content: flex-start; }
  .rb-metric-row, .rb-metric-row.rb-metric-calculation, .rb-metric-row.rb-metric-calc { grid-template-columns: 16px 1fr 30px; }
  .rb-metric-row .rb-metric-type, .rb-metric-row .rb-metric-tag { justify-self: start; }
  .rb-metric-row select, .rb-metric-row input, .rb-metric-row .rb-metric-formula { grid-column: 2 / 4; }
  .rb-metric-row .rb-metric-delete { grid-column: 3; grid-row: 1; }
}
