/* =====================================================
   U KPI 포털 — Editorial Pro 디자인
   기관 내부 분석 시스템 (총장/교직원/교수 시각)
   ===================================================== */

:root {
  --accent:        #1f4d3a;
  --accent-soft:   #1f4d3a0d;
  --accent-line:   #1f4d3a26;
  --bg:            #fbfaf6;
  --surface:       #ffffff;
  --ink:           #1c1917;          /* stone-900 */
  --ink-2:         #44403c;          /* stone-700 */
  --ink-3:         #78716c;          /* stone-500 */
  --ink-4:         #a8a29e;          /* stone-400 */
  --line:          #d6d3d1;          /* stone-300 */
  --line-soft:     #e7e5e4;          /* stone-200 */
  --hover:         #f5f5f4;          /* stone-100 */

  --header-h:      48px;
  --ctx-h:         40px;
  --sidebar-w:     288px;

  --serif:         'Noto Serif KR', 'Source Serif Pro', Georgia, serif;
  --sans:          'Pretendard', 'Noto Sans KR', -apple-system, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body.portal-body {
  margin: 0;
  padding: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* ─── Header (utility bar) ─── */
.portal-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 200;
}
.portal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 28px; height: 28px;
  border: 2px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
}
.brand-text {
  display: flex; flex-direction: column;
}
.brand-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  line-height: 1;
}
.brand-name .muted {
  color: var(--ink-4);
  font-weight: 400;
}
.brand-tag {
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
  margin-top: 2px;
}
@media (max-width: 900px) { .brand-tag { display: none; } }

.portal-nav {
  display: flex;
  gap: 20px;
  margin-left: 12px;
  font-family: var(--serif);
}
.portal-nav a {
  color: var(--ink-3);
  text-decoration: none;
  font-size: 14px;
  letter-spacing: -0.01em;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.12s;
}
.portal-nav a:hover { color: var(--ink); }
.portal-nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
}

.portal-search {
  flex: 1;
  max-width: 420px;
  margin-left: 16px;
  position: relative;
}
.portal-search input {
  width: 100%;
  padding: 6px 56px 6px 34px;
  font-size: 13px;
  font-family: var(--sans);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  outline: none;
  color: var(--ink);
  transition: border-color 0.12s;
}
.portal-search input::placeholder { color: var(--ink-4); }
.portal-search input:focus { border-color: var(--ink); }
.portal-search .icon {
  position: absolute;
  left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-4);
  font-size: 13px;
}
.portal-search .kbd {
  position: absolute;
  right: 8px; top: 50%; transform: translateY(-50%);
  font-family: ui-monospace, monospace;
  font-size: 10px;
  background: var(--hover);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 2px 6px;
  color: var(--ink-3);
}

.portal-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
}
.role-toggle {
  display: flex;
  gap: 2px;
  background: var(--hover);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 2px;
}
.role-toggle button {
  padding: 5px 10px;
  border: none;
  background: transparent;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  border-radius: 3px;
  letter-spacing: -0.01em;
  transition: all 0.12s;
}
.role-toggle button:hover { color: var(--ink); }
.role-toggle button.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.header-sep { color: var(--line); }
.portal-user-email {
  font-size: 13px;
  color: var(--ink-soft, #6b6b6b);
}
.portal-header-btn {
  background: none;
  border: none;
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  padding: 4px 0;
}
.portal-header-btn:hover { color: var(--ink); }
.portal-header-btn.portal-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 2px;
  color: var(--ink-3);
}
.portal-header-btn.portal-header-icon svg { display: block; }
.portal-header-btn.portal-header-icon:hover { color: var(--accent); }

/* 좁은 화면: 검색창 숨김 + 사용자 이메일 축약 */
@media (max-width: 1100px) {
  .portal-search { display: none; }
}
@media (max-width: 860px) {
  .portal-user-email { display: none; }
  .portal-header-right .header-sep:first-of-type { display: none; }
}
.portal-user {
  color: var(--ink-2);
  font-weight: 500;
  font-size: 12px;
}

/* ─── Profile menu ─── */
.profile-wrap { position: relative; }
.profile-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
  padding: 0;
}
.profile-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.profile-btn.active { color: var(--accent); border-color: var(--accent); }
.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px -6px rgba(0,0,0,0.15);
  z-index: 900;
  padding: 6px 0;
}
.profile-dd-email {
  padding: 8px 14px 6px;
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-dd-sep {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}
.profile-dd-item {
  display: block;
  padding: 7px 14px;
  font-size: 12px;
  color: var(--ink-2);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s;
}
.profile-dd-item:hover { background: var(--hover); color: var(--ink); }
.profile-dd-logout { color: #c0392b; }
.profile-dd-logout:hover { background: #fff5f5; color: #c0392b; }

/* ─── Context bar ─── */
.portal-context {
  position: fixed;
  top: var(--header-h); left: 0; right: 0;
  height: var(--ctx-h);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 0 24px;
  gap: 8px;
  z-index: 199;
  font-size: 12px;
  scrollbar-width: none;
}
.portal-context::-webkit-scrollbar { display: none; }
.ctx-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-right: 4px;
}
.ctx-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s;
}
.ctx-chip:hover { background: var(--hover); }
.ctx-chip.primary {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.ctx-chip .ico { width: 13px; height: 13px; flex-shrink: 0; color: var(--ink-2); }
.ctx-chip .caret { width: 11px; height: 11px; margin-left: 2px; flex-shrink: 0; color: var(--ink-2); }
.ctx-chip.primary .ico,
.ctx-chip.primary .caret { color: var(--accent); }
.ctx-chip .muted { opacity: 0.6; }
.ctx-chip .ctx-chip-prefix { font-weight: 400; opacity: 0.7; }
.ctx-sep { color: var(--ink-4); }
.ctx-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}
.ctx-actions button,
.ctx-actions .ctx-action-btn {
  padding: 5px 10px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.12s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1.4;
}
.ctx-actions button:hover,
.ctx-actions .ctx-action-btn:hover { background: var(--hover); color: var(--ink); }
.ctx-actions .ctx-icon-btn {
  padding: 5px 7px;
  color: var(--ink-3);
}
.ctx-actions .ctx-icon-btn svg { display: block; }
.ctx-actions .ctx-icon-btn:hover { color: var(--accent); background: var(--hover); }
.ctx-actions button.primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.ctx-actions button.primary:hover { background: #173a2c; color: #fff; }

.ctx-actions-divider {
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 4px;
  align-self: center;
}
.ctx-actions .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 7px;
  color: var(--ink-2);
}
.ctx-actions .icon-btn svg {
  flex-shrink: 0;
  color: var(--ink-2);
}
.ctx-actions .icon-btn:hover svg { color: var(--accent); }
.ctx-actions .icon-btn .icon-btn-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}
.ctx-actions .icon-btn:hover .icon-btn-tag { color: var(--accent); }

/* ─── Layout ─── */
.portal-layout {
  display: flex;
  margin-top: calc(var(--header-h) + var(--ctx-h));
  min-height: calc(100vh - var(--header-h) - var(--ctx-h));
}

/* ─── Sidebar ─── */
.portal-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  background: var(--bg);
  padding: 24px 20px;
  position: sticky;
  top: calc(var(--header-h) + var(--ctx-h));
  align-self: flex-start;
  height: calc(100vh - var(--header-h) - var(--ctx-h));
  overflow-y: auto;
  /* KPI 셀렉터는 컨텍스트바 칩 팝오버로 이주됨 — 사이드바 자체는 숨김 */
  display: none;
}
.sidebar-resizer { display: none; }

/* ─── Sidebar Resizer ─── */
.sidebar-resizer {
  position: sticky;
  top: calc(var(--header-h) + var(--ctx-h));
  align-self: stretch;
  flex: 0 0 5px;
  width: 5px;
  margin-left: -5px;
  height: calc(100vh - var(--header-h) - var(--ctx-h));
  cursor: col-resize;
  background: transparent;
  z-index: 50;
  transition: background 0.15s;
}
.sidebar-resizer:hover,
.sidebar-resizer.dragging { background: var(--accent-soft); }
body.sidebar-dragging { cursor: col-resize !important; user-select: none; }
body.sidebar-dragging * { cursor: col-resize !important; user-select: none !important; }
.sidebar-block { margin-bottom: 28px; }

/* ── 사이드바 관리자 메뉴 그룹 ── */
.admin-menu-block { margin-bottom: 20px; }
.admin-menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.admin-menu-item {
  display: block;
  padding: 6px 10px 6px 18px;
  font-size: 12px;
  color: var(--ink-2);
  text-decoration: none;
  position: relative;
  border-radius: 2px;
  transition: background 0.12s, color 0.12s;
}
.admin-menu-item::before {
  content: "ㄴ";
  position: absolute;
  left: 4px;
  color: var(--ink-3);
  font-size: 10px;
}
.admin-menu-item:hover {
  background: var(--hover);
  color: var(--accent);
}
.admin-menu-item[aria-disabled="true"] { cursor: default; color: var(--ink-3); }
.admin-menu-item[aria-disabled="true"]:hover { background: transparent; color: var(--ink-2); }
.sidebar-block-header {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 6px;
  margin-bottom: 12px;
}
.kpi-counts-btn {
  background: transparent;
  border: none;
  padding: 2px 4px;
  margin: -2px -4px;
  font-family: inherit;
  cursor: help;
  border-radius: 2px;
  transition: background 0.12s, color 0.12s;
}
.kpi-counts-btn:hover,
.kpi-counts-btn[aria-expanded="true"] {
  background: var(--hover);
  color: var(--accent);
}
.kpi-counts-pop {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  width: 220px;
  background: #fff;
  border: 1px solid var(--ink);
  border-radius: 3px;
  padding: 10px 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  font-family: var(--sans);
}
.kpi-counts-pop[hidden] { display: none; }
.kpi-counts-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
  padding: 3px 0;
}
.kpi-counts-row b {
  display: inline-block;
  min-width: 28px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.kpi-counts-foot {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.sidebar-block-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}
.sidebar-block-meta {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* All-of-institution row */
.org-all {
  padding: 6px 0 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.org-all-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--serif);
  color: var(--ink-2);
}
.org-all.active .org-all-row {
  color: var(--accent);
  font-weight: 700;
}
.org-all-row .icon { font-size: 12px; }
.org-all-row .label { flex: 1; }
.org-all-row .badge {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-3);
  opacity: 0.7;
}
.org-all-meta {
  font-family: var(--sans);
  font-size: 10px;
  color: var(--ink-3);
  margin-left: 20px;
  margin-top: 2px;
}

/* Closed-toggle */
.org-closed-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--ink-2);
  cursor: pointer;
}
.org-closed-toggle input { accent-color: var(--ink-2); }

/* Campus / category / unit tree */
.org-tree { list-style: none; margin: 0; padding: 0; }
.org-tree li { list-style: none; }

.org-campus-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
  font-family: var(--serif);
  color: var(--ink-2);
}
.org-campus-row:hover { color: var(--ink); }
.org-campus-row .caret {
  font-family: var(--sans);
  font-size: 10px;
  color: var(--ink-4);
  width: 12px;
}
.org-campus-row .label {
  font-weight: 600;
  flex: 1;
}
.org-campus-row .label .alias {
  font-weight: 400;
  font-size: 12px;
  color: var(--ink-4);
}
.org-campus-row .count {
  font-family: var(--sans);
  font-size: 10px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}
.org-campus-loc {
  font-family: var(--sans);
  font-size: 10px;
  color: var(--ink-3);
  margin: -2px 0 4px 20px;
}

.org-cats {
  list-style: none;
  margin: 2px 0 0 20px;
  padding-left: 12px;
  border-left: 1px solid var(--line-soft);
}
.org-cat-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
  cursor: pointer;
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ink-2);
}
.org-cat-row:hover { color: var(--ink); }
.org-cat-row .caret {
  font-family: var(--sans);
  font-size: 9px;
  color: var(--ink-4);
  width: 10px;
}
.org-cat-row .label { flex: 1; }
.org-cat-row .count {
  font-family: var(--sans);
  font-size: 10px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

.org-units {
  list-style: none;
  margin: 1px 0 0 16px;
  padding-left: 10px;
  border-left: 1px solid var(--line-soft);
}
.org-unit-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 0;
  font-family: var(--serif);
  font-size: 12.5px;
  color: var(--ink-3);
  cursor: pointer;
}
.org-unit-row:hover { color: var(--ink); }
.org-unit-row.active {
  color: var(--accent);
  font-weight: 700;
}
.org-unit-row.closed {
  color: var(--ink-4);
}
.org-unit-row.closed .name { text-decoration: line-through; }
.org-unit-row .name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.org-unit-row .tag {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 500;
}
.org-unit-row.active .tag { color: var(--accent); opacity: 0.7; }

/* hide tree levels via .hidden */
.hidden { display: none !important; }

/* ─── KPI 검색결과 패널 (우측 도킹) ─── */
.kpi-results-panel {
  position: fixed;
  top: 110px; /* header(56) + context bar(54) 아래 */
  right: 24px;
  width: 380px;
  max-height: calc(100vh - 140px);
  background: #fff;
  border: 0.5px solid rgba(0,0,0,0.18);
  border-radius: 14px;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,0.22), 0 4px 12px -4px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  z-index: 80;
  font-family: var(--sans);
  overflow: hidden;
  animation: kpi-results-slide-in 0.18s ease-out;
}
.kpi-results-panel[hidden] { display: none; }
@keyframes kpi-results-slide-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}
.kpi-results-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 0.5px solid rgba(0,0,0,0.1);
  background: var(--accent);
  color: #fff;
}
.kpi-results-eyebrow {
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 700;
  opacity: 0.7;
  margin-bottom: 4px;
}
.kpi-results-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.kpi-results-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.kpi-results-close:hover { background: rgba(255,255,255,0.28); }
.kpi-results-summary {
  padding: 10px 16px 0;
  font-size: 11px;
  color: #5f5e5a;
  font-variant-numeric: tabular-nums;
}
.kpi-results-summary b { color: var(--ink); font-weight: 600; }
.kpi-results-chips {
  padding: 8px 16px 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.kpi-results-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 999px;
  background: #f5f5f4;
  color: #5f5e5a;
  border: 0.5px solid rgba(0,0,0,0.1);
}
.kpi-results-chip .x {
  cursor: pointer;
  color: #9b9a95;
  font-weight: 700;
}
.kpi-results-chip .x:hover { color: var(--ink); }
.kpi-results-body {
  overflow-y: auto;
  padding: 10px 16px 14px;
  flex: 1;
}
.kpi-results-empty {
  padding: 24px 8px;
  text-align: center;
  color: #9b9a95;
  font-size: 12px;
}
.kpi-param-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 0.5px dashed rgba(0,0,0,0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}
.kpi-param-row:last-child { border-bottom: none; }
.kpi-param-row .k {
  color: #9b9a95;
  font-weight: 600;
  min-width: 110px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
}
.kpi-param-row .v {
  color: var(--ink);
  flex: 1;
  word-break: break-word;
}
.kpi-results-field-group { margin-top: 12px; }
.kpi-results-field-group:first-child { margin-top: 4px; }
.kpi-results-field-name {
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.kpi-results-field-name .n {
  font-family: var(--sans);
  font-size: 10px;
  color: #9b9a95;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.kpi-results-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
}
.kpi-results-row:hover { background: #f5f5f4; }
.kpi-results-row .code {
  font-family: var(--sans);
  font-size: 10px;
  color: #9b9a95;
  font-weight: 600;
  min-width: 48px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi-results-row .name { color: var(--ink); flex: 1; }
.kpi-results-row.sub .code { color: #b8b8b3; }
.kpi-results-row.sub .name { color: #5f5e5a; }
.kpi-results-row .kpi-hl {
  background: #faeeda;
  color: #854f0b;
  padding: 0 2px;
  border-radius: 3px;
}
.kpi-results-foot {
  padding: 10px 16px;
  border-top: 0.5px solid rgba(0,0,0,0.1);
  background: #fbfaf6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #5f5e5a;
}
.kpi-results-foot b { color: var(--ink); font-weight: 600; }
.kpi-results-clear {
  border: 0.5px solid rgba(0,0,0,0.18);
  background: #fff;
  color: var(--ink);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.kpi-results-clear:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 1280px) {
  .kpi-results-panel { width: 340px; }
}
@media (max-width: 1024px) {
  .kpi-results-panel {
    right: 12px;
    left: 12px;
    width: auto;
    top: auto;
    bottom: 12px;
    max-height: 60vh;
  }
}

/* ─── KPI Selector v7 (격리된 스타일) ─── */
.kpi-selector {
  --kpi-bg-info:        #e6f1fb;
  --kpi-text-info:      #185fa5;
  --kpi-bg-warning:     #faeeda;
  --kpi-text-warning:   #854f0b;
  --kpi-text-secondary: #5f5e5a;
  --kpi-text-tertiary:  #9b9a95;
  --kpi-border-tert:    rgba(0, 0, 0, 0.12);
  --kpi-border-sec:     rgba(0, 0, 0, 0.24);
  font-family: var(--sans);
}

/* 검색창 */
.kpi-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 0.5px solid var(--kpi-border-sec);
  border-radius: 8px;
  margin-bottom: 12px;
  background: #fff;
}
.kpi-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
  padding: 0;
  min-width: 0;
  color: var(--ink);
  font-family: inherit;
}
.kpi-search input::placeholder { color: var(--kpi-text-tertiary); }
.kpi-search-icon, .kpi-clear-icon {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--kpi-text-secondary);
  flex-shrink: 0;
}
.kpi-clear-icon { cursor: pointer; color: var(--kpi-text-tertiary); display: none; }

/* 모드 토글 */
.kpi-mode-toggle {
  display: flex;
  gap: 0;
  padding: 2px;
  background: var(--hover);
  border-radius: 8px;
  margin-bottom: 14px;
}
.kpi-mode-btn {
  flex: 1;
  padding: 5px 0;
  font-size: 11px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  background: transparent;
  color: var(--kpi-text-secondary);
  font-family: inherit;
}
.kpi-mode-btn.active {
  background: #fff;
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 0 0 0.5px var(--kpi-border-tert);
}

/* 분야/그룹 헤더 */
.kpi-field-section { margin-bottom: 14px; }
.kpi-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--kpi-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.kpi-clear-field {
  cursor: pointer;
  color: var(--kpi-text-info);
  text-transform: none;
  font-size: 11px;
  display: none;
}

/* 분야 칩 그리드 */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.kpi-grid-extra { display: none; margin-top: 4px; }
.kpi-chip {
  padding: 5px 8px 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
  line-height: 1.3;
  user-select: none;
  border: 0.5px solid var(--kpi-border-tert);
  color: var(--kpi-text-secondary);
  background: transparent;
  font-family: inherit;
}
.kpi-chip.group { text-align: center; padding: 6px 6px; }
.kpi-chip.active {
  background: var(--kpi-bg-info);
  color: var(--kpi-text-info);
  font-weight: 500;
  border-color: transparent;
}
.kpi-chip.group { padding: 6px 6px; }
.kpi-badge {
  display: inline-block;
  background: var(--kpi-bg-warning);
  color: var(--kpi-text-warning);
  padding: 0 4px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 500;
  margin-left: 2px;
}
.kpi-chip.active .kpi-badge { background: rgba(255, 255, 255, 0.3); color: inherit; }

/* 기타 펼치기 토글 */
.kpi-toggle-extra {
  display: none;
  margin-top: 6px;
  width: 100%;
  padding: 4px;
  font-size: 11px;
  color: var(--kpi-text-secondary);
  border: 0.5px dashed var(--kpi-border-tert);
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}

/* 트리 */
.kpi-tree-section {
  border-top: 0.5px solid var(--kpi-border-tert);
  padding-top: 12px;
}
.kpi-tree-header {
  font-size: 10px;
  color: var(--kpi-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.kpi-tree { font-size: 12px; line-height: 1.7; }
.kpi-tree-empty {
  color: var(--kpi-text-tertiary);
  padding: 8px 4px;
  font-size: 11px;
}
.kpi-tree-field-header {
  font-weight: 500;
  color: var(--ink);
  margin-top: 8px;
  font-size: 11px;
}
.kpi-tree-node {
  padding: 1px 4px 1px 10px;
  color: var(--kpi-text-secondary);
  font-size: 11px;
  cursor: pointer;
}
.kpi-tree-node:hover { color: var(--ink); }
.kpi-hl {
  background: var(--kpi-bg-warning);
  color: var(--kpi-text-warning);
  padding: 0 2px;
  border-radius: 3px;
}

/* ─── Content ─── */
.portal-content {
  flex: 1;
  min-width: 0;
  padding: 28px 40px;
  background: var(--bg);
}
.portal-content-inner { width: 100%; }

/* /report 페이지는 컴팩트 패딩 (좌·상 10px) */
.portal-content:has(.report-page) {
  padding: 5px 20px 14px 5px;
}

/* Article header used by pages */
.article-header {
  border-bottom: 1px solid var(--ink);
  padding-bottom: 16px;
  margin-bottom: 20px;
}
.article-eyebrow {
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}
.article-title {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0;
  color: var(--ink);
}
.article-lead {
  font-size: 14px;
  color: var(--ink-2);
  margin-top: 8px;
  max-width: 640px;
  line-height: 1.6;
}

/* Existing dashboard frame inside portal */
.portal-body .app-root {
  padding: 0;
  min-height: 100%;
  align-items: flex-start;
}
.portal-body .dashboard-frame {
  width: 100%;
  margin: 0 auto;
  box-shadow: none;
  background: transparent;
}

.hover-tip {
  position: absolute;
  display: none;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  padding: 6px 10px;
  border-radius: 3px;
  font-size: 11px;
  z-index: 1000;
}

/* ─── Login Page (kept compatible) ─── */
body.login-body {
  margin: 0; padding: 0;
  font-family: var(--sans);
  background: var(--bg);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 48px 44px;
  width: 460px;
  box-shadow: 0 4px 24px rgba(28,25,23,0.06);
}
.login-logo-wrap { text-align: center; margin-bottom: 4px; }
.login-logo { height: auto; width: 57.6%; max-width: 260px; object-fit: contain; }
.login-links { margin-top: 14px; text-align: center; font-size: 13px; color: var(--ink-3); }
.login-links a { color: var(--ink-2); text-decoration: none; }
.login-links a:hover { color: var(--accent); text-decoration: underline; }
.login-links-sep { margin: 0 8px; color: var(--line); }
.login-title {
  text-align: center; font-family: var(--serif);
  font-size: 22px; font-weight: 700;
  color: var(--ink); margin: 0 0 4px 0;
}
.login-sub {
  text-align: center; font-size: 16px;
  color: var(--ink-3); margin: 0 0 32px 0;
}
.login-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 20px 0; color: var(--ink-4); font-size: 11px;
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line-soft);
}
.login-field { margin-bottom: 14px; }
.login-field label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--ink-2); margin-bottom: 5px;
}
.login-field input {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--line); border-radius: 4px;
  font-size: 13px; font-family: inherit; outline: none;
  transition: border-color 0.15s;
}
.login-field input:focus { border-color: var(--accent); }
.login-hint { font-size: 11px; color: var(--ink-4); margin: -8px 0 16px 0; }
.login-btn {
  width: 100%; padding: 12px; border: none; border-radius: 4px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: opacity 0.15s, transform 0.1s;
}
.login-btn:active { transform: scale(0.98); }
.login-btn.primary { background: #2563eb; color: #fff; margin-top: 4px; }
.login-btn.primary:hover { background: #1d4ed8; opacity: 1; }
.login-btn.google {
  background: #fff; color: #3c4043;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 10px;
}
.login-btn.google:hover { background: var(--hover); }
.login-btn.microsoft {
  background: #fff; color: #3c4043;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  opacity: 0.6; cursor: not-allowed;
}
.login-btn svg { width: 18px; height: 18px; }
.login-error {
  background: #fdf0f0; border: 1px solid #f5c6c6;
  border-radius: 4px; padding: 10px 13px;
  color: #c0392b; font-size: 12px; margin-bottom: 16px;
}
.login-footer { text-align: center; font-size: 11px; color: var(--ink-4); margin-top: 28px; }

/* ─── Admin Page (kept compatible) ─── */
.admin-body { background: var(--bg); }
.admin-page { max-width: 1000px; margin: 0 auto; padding: 28px 24px; }
.admin-section {
  background: var(--surface); border-radius: 4px;
  border: 1px solid var(--line); margin-bottom: 20px; overflow: hidden;
}
.admin-section-header {
  padding: 14px 20px;
  font-family: var(--serif); font-size: 16px; font-weight: 700;
  color: var(--ink); border-bottom: 1px solid var(--line);
  background: var(--bg);
  display: flex; align-items: center; justify-content: space-between;
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-table th {
  background: var(--bg); padding: 9px 16px; text-align: left;
  font-weight: 600; color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
}
.admin-table td { padding: 10px 16px; border-bottom: 1px solid var(--line-soft); color: var(--ink); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--hover); }
.role-badge {
  display: inline-block; padding: 2px 9px; border-radius: 2px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
}
.role-badge.admin   { background: var(--accent); color: #fff; }
.role-badge.manager { background: #e8f5e9; color: #1e7e34; }
.role-badge.user    { background: #e8f0fe; color: #1a4db8; }
.role-badge.guest   { background: #f0f0f0; color: #666; }
.admin-action-btn {
  padding: 5px 12px; border-radius: 3px;
  border: 1px solid var(--line); background: #fff;
  cursor: pointer; font-size: 11px; font-family: inherit; color: var(--ink);
  transition: background 0.12s;
}
.admin-action-btn:hover { background: var(--hover); }
.admin-action-btn.danger { color: #c0392b; border-color: #f5c6c6; }
.admin-action-btn.danger:hover { background: #fdeaea; }
.admin-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--line);
}
.admin-stat { background: var(--surface); padding: 16px 20px; text-align: center; }
.admin-stat .stat-num {
  font-family: var(--serif);
  font-size: 28px; font-weight: 700;
  color: var(--accent);
}
.admin-stat .stat-label { font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.admin-form { padding: 16px 20px; display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.admin-form-group { display: flex; flex-direction: column; gap: 4px; }
.admin-form-group label { font-size: 11px; font-weight: 500; color: var(--ink-3); }
.admin-form-group input,
.admin-form-group select {
  padding: 7px 10px; border: 1.5px solid var(--line);
  border-radius: 4px; font-size: 12px; font-family: inherit;
  outline: none; min-width: 180px;
}
.admin-form-group input:focus,
.admin-form-group select:focus { border-color: var(--accent); }
.admin-submit-btn {
  padding: 8px 18px; background: var(--accent); color: #fff;
  border: none; border-radius: 4px; font-size: 12px;
  font-weight: 600; cursor: pointer; font-family: inherit;
}
.admin-submit-btn:hover { opacity: 0.9; }
.cache-status { padding: 14px 20px; display: flex; flex-wrap: wrap; gap: 10px; }
.cache-btn {
  padding: 7px 15px; background: #fff; border: 1px solid var(--line);
  border-radius: 4px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.cache-btn:hover { background: var(--hover); }
.cache-result { font-size: 12px; color: var(--accent); padding: 7px 0; }

/* ============================================================
   AI · 컨텍스트 셀렉터 팝오버 (현재 보기 가톨릭대학교)
   ============================================================ */
.ctx-chip-wrap { position: relative; display: inline-block; }
.ctx-popover {
  position: absolute;
  top: calc(100% + 6px); left: 0;
  width: 360px;
  max-height: 480px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--ink-2);
  border-radius: 4px;
  box-shadow: 0 14px 40px -10px rgba(0,0,0,0.2);
  z-index: 600;
  padding: 8px 0;
  font-family: var(--sans);
}
.ctx-popover[hidden] { display: none; }
.ctx-pop-head {
  padding: 4px 14px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.ctx-pop-eyebrow {
  font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700;
}
.ctx-pop-tree { list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--ink); }
.ctx-pop-tree ul { list-style: none; margin: 0; padding: 0; }

/* 대학교 셀렉터 검색창 */
.ctx-pop-search {
  position: relative;
  padding: 6px 10px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.ctx-pop-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 28px 6px 10px;
  font-size: 12.5px;
  font-family: var(--sans);
  color: var(--ink);
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 3px;
  outline: none;
}
.ctx-pop-search input:focus { border-color: var(--accent); background: #fff; }
.ctx-pop-search .clear-btn {
  position: absolute;
  right: 16px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  border: 0; background: transparent;
  color: var(--ink-3); font-size: 16px; line-height: 1;
  cursor: pointer; visibility: hidden;
}
.ctx-pop-search .clear-btn:hover { color: var(--ink); }
.ctx-pop-univ { list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--ink); }
.ctx-pop-empty {
  padding: 14px 14px 10px;
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
}
.ctx-pop-empty[hidden] { display: none; }

/* KPI 셀렉터 팝오버 (사이드바 패널 이주 컨테이너) */
.ctx-popover.ctx-popover-wide {
  width: 440px;
  max-height: calc(100vh - var(--header-h) - var(--ctx-h) - 40px);
  padding: 8px 0 12px;
}
.ctx-kpi-mount { padding: 4px 14px 0; }
.ctx-kpi-mount .kpi-selector { margin: 0; }
.ctx-kpi-mount .sidebar-block-header { margin-top: 0; }

.ctxp-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 14px;
  cursor: pointer;
  user-select: none;
}
.ctxp-row:hover { background: var(--hover); }
.ctxp-row.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ctxp-pick { flex: 1; display: flex; align-items: center; gap: 8px; }
.ctxp-caret {
  display: inline-block; width: 20px; text-align: center;
  color: var(--ink-2); font-size: 16px; font-weight: 700;
  flex-shrink: 0;
}
.ctxp-caret:hover { color: var(--accent); }
.ctxp-ic { font-size: 14px; }
.ctxp-label { font-family: var(--serif); }
.ctxp-label .muted { color: var(--ink-3); font-weight: 400; font-family: var(--sans); font-size: 11px; }
.ctxp-cnt {
  font-size: 10px; color: var(--ink-3);
  background: var(--bg); padding: 1px 6px; border-radius: 8px;
}
.ctxp-tag {
  font-size: 9px; letter-spacing: 0.1em;
  padding: 1px 6px;
  background: var(--accent); color: #fff;
  border-radius: 2px;
  font-weight: 700;
}
.ctxp-all { border-bottom: 1px dashed var(--line); padding-bottom: 8px; margin-bottom: 4px; }
.ctxp-all .ctxp-label { font-weight: 700; }
.ctxp-cat-row { padding-left: 28px; font-weight: 400; }
.ctxp-cat-row .ctxp-label { font-weight: 400; }
.ctxp-unit-row {
  padding-left: 64px; font-size: 12px;
  position: relative;
}
.ctxp-unit-row::before {
  content: "└";
  position: absolute;
  left: 48px;
  color: var(--ink-4, #bbb);
  font-size: 11px;
}
.ctxp-unit-row.active::before { color: var(--accent); }
.ctxp-camp-row { padding-left: 14px; font-weight: 600; }

/* ============================================================
   RAG 봇 — 데스크탑 알약 FAB / 모바일 풀스크린 시트
   ============================================================ */
.rag-root { font-family: var(--sans); }

/* idle hint bubble (데스크탑) */
.rag-hint {
  position: fixed;
  left: 24px; bottom: 96px;
  max-width: 280px;
  background: #fff;
  border: 1px solid var(--ink-2);
  border-radius: 14px 14px 14px 4px;
  padding: 12px 30px 12px 14px;
  box-shadow: 0 12px 30px -8px rgba(0,0,0,0.18);
  z-index: 599;
  font-family: var(--serif);
}
.rag-hint-x {
  position: absolute;
  top: 4px; right: 6px;
  width: 22px; height: 22px;
  border: 0; background: transparent;
  font-size: 18px; line-height: 1;
  color: var(--ink-3); cursor: pointer;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  transition: background 0.12s, color 0.12s;
}
.rag-hint-x:hover { background: var(--accent-soft); color: var(--accent); }
.rag-hint-eyebrow {
  font-family: var(--sans);
  font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--accent); font-weight: 700; margin-bottom: 4px;
}
.rag-hint-body {
  font-size: 13px; line-height: 1.5; color: var(--ink);
}
.rag-hint-foot {
  font-family: var(--sans);
  font-size: 10px; color: var(--ink-3); margin-top: 6px;
}

/* FAB (데스크탑 알약) */
.rag-fab {
  position: fixed;
  left: 24px; bottom: 24px;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 22px 10px 10px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 16px 36px -10px rgba(31,77,58,0.5);
  z-index: 600;
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: var(--sans);
}
.rag-fab:hover { transform: translateY(-2px); box-shadow: 0 22px 50px -10px rgba(31,77,58,0.6); }
.rag-fab-orb {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rag-fab-ping {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  animation: ragPing 2.2s cubic-bezier(0,0,0.2,1) infinite;
}
@keyframes ragPing {
  0%   { transform: scale(1);   opacity: 0.7; }
  75%  { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1.6); opacity: 0; }
}
.rag-fab-icon { font-size: 18px; position: relative; }
.rag-fab-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.rag-fab-eyebrow {
  font-size: 9px; letter-spacing: 0.25em; text-transform: uppercase;
  opacity: 0.75; font-weight: 600;
}
.rag-fab-title {
  font-family: var(--serif);
  font-size: 15px; font-weight: 700; margin-top: 1px;
}
.rag-fab-kbd {
  font-size: 10px; opacity: 0.55; margin-left: 6px;
  border: 1px solid rgba(255,255,255,0.3); padding: 1px 5px; border-radius: 3px;
}

body.rag-open .rag-hint { display: none; }

/* Desktop Panel */
.rag-panel {
  position: fixed;
  left: 24px; bottom: 24px;
  width: 420px; height: 580px;
  background: #fff;
  border: 1px solid var(--ink-2);
  border-radius: 14px;
  box-shadow: 0 24px 50px -12px rgba(0,0,0,0.25);
  z-index: 601;
  display: flex; flex-direction: column;
  overflow: hidden;
  font-family: var(--sans);
}
.rag-panel[hidden] { display: none; }
.rag-panel-head {
  background: var(--accent); color: #fff;
  padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.rag-panel-head-l { display: flex; align-items: center; gap: 10px; }
.rag-panel-icon { font-size: 20px; }
.rag-panel-title { font-family: var(--serif); font-size: 15px; font-weight: 700; line-height: 1.2; }
.rag-panel-sub { font-size: 10px; opacity: 0.7; letter-spacing: 0.08em; }
.rag-panel-close {
  background: none; border: none; color: rgba(255,255,255,0.85);
  font-size: 22px; cursor: pointer; line-height: 1;
}
.rag-panel-close:hover { color: #fff; }

.rag-panel-body {
  flex: 1; overflow: auto;
  padding: 18px;
}
.rag-suggest-eyebrow {
  font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700; margin-bottom: 10px;
}
.rag-suggest { display: flex; flex-direction: column; gap: 8px; }
.rag-sug-btn {
  text-align: left;
  padding: 11px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--serif);
  font-size: 13px; color: var(--ink);
  transition: border-color 0.12s, background 0.12s;
}
.rag-sug-btn:hover { border-color: var(--ink); background: var(--bg); }

.rag-panel-input {
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.rag-input-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px 6px 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.12s;
}
.rag-input-wrap:focus-within { border-color: var(--accent); }
.rag-input-icon { color: var(--ink-3); }
#rag-q {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 13px; font-family: var(--sans); color: var(--ink);
  padding: 6px 0;
}
.rag-input-send {
  width: 32px; height: 32px;
  border: none; border-radius: 50%;
  background: var(--accent); color: #fff;
  cursor: pointer; font-size: 14px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.rag-input-send:hover { background: #173a2c; }

/* Mobile (≤768px): 변형 C — AI 우선 풀스크린 시트 */
@media (max-width: 768px) {
  .rag-hint { display: none; }
  .rag-fab {
    left: auto; right: 18px; bottom: 18px;
    padding: 12px;
    border-radius: 50%;
  }
  .rag-fab-text, .rag-fab-kbd { display: none; }
  .rag-fab-orb { width: 44px; height: 44px; }

  .rag-panel {
    left: 0; right: 0; top: 0; bottom: 0;
    width: 100%; height: 100%;
    border-radius: 0;
    border: none;
  }
  .rag-panel-head { padding: 14px 18px; }
  .rag-panel-body { padding: 22px; }
  .rag-suggest-eyebrow { font-size: 10px; }
  .rag-sug-btn {
    padding: 14px 16px;
    border-radius: 14px;
    font-size: 14px;
  }
  .rag-panel-input {
    padding: 14px;
  }
  .rag-input-wrap {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    padding: 8px 8px 8px 16px;
  }
  .rag-input-wrap:focus-within { border-color: var(--accent); }
  .rag-input-icon { color: rgba(255,255,255,0.85); }
  #rag-q { color: #fff; }
  #rag-q::placeholder { color: rgba(255,255,255,0.65); }
  .rag-input-send { background: #fff; color: var(--accent); }
  .rag-input-send:hover { background: #f1efe7; }
}

/* ============================================================
   AI · 자연어 분석결과 패널 (우측)
   ============================================================ */
.ai-results-panel {
  position: fixed;
  top: calc(var(--header-h) + var(--ctx-h) + 16px);
  right: 24px;
  width: 380px;
  max-height: calc(100vh - var(--header-h) - var(--ctx-h) - 40px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--ink-2);
  border-radius: 6px;
  box-shadow: 0 16px 40px -12px rgba(0,0,0,0.22);
  z-index: 590;
  font-family: var(--sans);
  display: flex; flex-direction: column;
}
.ai-results-panel[hidden] { display: none; }
.ai-results-head {
  background: var(--accent); color: #fff;
  padding: 12px 16px;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px;
}
.ai-results-eyebrow {
  font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase;
  opacity: 0.8; font-weight: 700;
}
.ai-results-title {
  font-family: var(--serif);
  font-size: 14px; font-weight: 700; margin-top: 2px;
}
.ai-results-close {
  background: none; border: none; color: rgba(255,255,255,0.85);
  font-size: 20px; cursor: pointer; line-height: 1;
}
.ai-results-close:hover { color: #fff; }

.ai-results-q {
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.ai-q-eyebrow {
  font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700; margin-bottom: 4px;
}
.ai-q-text {
  font-family: var(--serif);
  font-size: 13px; color: var(--ink); line-height: 1.4;
}

.ai-results-body { padding: 6px 0; }
.ai-param-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.ai-param-row:last-child { border-bottom: none; }
.ai-param-k {
  font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700;
}
.ai-param-v {
  font-family: 'JetBrains Mono', 'Menlo', monospace;
  font-size: 13px; color: var(--accent); font-weight: 700;
  margin-top: 4px;
  word-break: break-all;
}
.ai-param-why {
  font-size: 11px; color: var(--ink-3);
  margin-top: 4px; line-height: 1.4;
}
.ai-results-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: 10px; color: var(--ink-3);
}

@media (max-width: 1280px) {
  .ai-results-panel { width: 340px; }
}
@media (max-width: 1024px) {
  .ai-results-panel {
    position: fixed;
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%;
    max-height: 60vh;
    border-radius: 0;
    border-top: 2px solid var(--accent);
  }
}

/* ============================================================
   /report 페이지 — 미니멀 상태 헤더 + 빈 결과 캔버스
   ============================================================ */
.report-page {
  padding: 9px 11px;
  font-family: var(--sans);
  min-height: calc(100vh - var(--header-h) - var(--ctx-h) - 36px);
}
.report-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 600px;
  display: flex; flex-direction: column;
}
.report-status {
  position: relative;
  padding: 18px 26px 16px;
  border-bottom: 1px solid var(--line);
}
.report-actions {
  position: absolute;
  top: 12px;
  right: 14px;
  display: flex;
  gap: 2px;
  align-items: center;
}
.report-actions .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 7px;
  background: transparent;
  border: none;
  border-radius: 2px;
  color: var(--ink-2);
  font-family: var(--sans);
  cursor: pointer;
  transition: background 0.12s;
}
.report-actions .icon-btn:hover { background: var(--hover); }
.report-actions .icon-btn svg { color: var(--ink-2); }
.report-actions .icon-btn:hover svg { color: var(--accent); }
.report-actions .icon-btn .icon-btn-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}
.report-actions .icon-btn:hover .icon-btn-tag { color: var(--accent); }
.report-status-eyebrow {
  font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600; margin-bottom: 6px;
}
.report-status-title {
  font-family: var(--serif);
  font-size: 15px; color: var(--ink);
  display: flex; align-items: baseline; flex-wrap: wrap;
  gap: 8px; line-height: 1.5;
}
.report-status-title .muted {
  color: var(--ink-3); font-weight: 400;
}
.rs-source {
  font-family: var(--sans);
  font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase;
  font-weight: 700;
  color: #fff; background: var(--accent);
  padding: 2px 7px; border-radius: 2px;
  align-self: center;
}
.rs-q {
  font-weight: 600;
  color: var(--ink);
}
.rs-sep { color: var(--ink-4); font-size: 12px; }
.rs-tag {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-2);
}
.rs-tag i {
  font-style: normal;
  font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700;
  margin-right: 4px;
}
.rs-tag-kpi { color: var(--accent); font-weight: 600; }

.report-status-meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-3);
  display: flex; flex-wrap: wrap; gap: 6px;
  line-height: 1.6;
}
.report-status-meta b { color: var(--ink-2); font-weight: 700; }
.rs-meta-sep { color: var(--ink-4); }
.rs-why {
  font-family: 'JetBrains Mono', 'Menlo', monospace;
  font-size: 10.5px;
}

.report-canvas {
  flex: 1;
  min-height: 480px;
}

/* KPI 트리 항목 — 클릭 가능 표시 */
.kpi-tree-node-link {
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  border-radius: 3px;
  padding: 2px 6px;
}
.kpi-tree-node-link:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
