/* =========================================
   Application CSS
   Base layout, theme, survey editor,
   analysis, results dashboard v2/v4, VoC
   ========================================= */

/* ── Base Styles ── */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%;
}

/* ── Header Navigation ── */
/* ===== 헤더 네비게이션 ===== */
.header-nav {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-nav nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 800px;
    margin: 0 auto;
}

.header-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.header-nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
}

.header-nav strong {
    font-size: 1.1rem;
    color: var(--text);
}

/* 테마 토글 */
.theme-toggle {
    position: relative;
}

.theme-btn {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.theme-btn:hover {
    background: var(--border);
}

.theme-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow);
    min-width: 120px;
    z-index: 200;
}

.theme-menu.show {
    display: block;
}

.theme-menu button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
}

.theme-menu button:hover {
    background: var(--bg-hover);
}

.theme-menu button.active {
    color: var(--primary);
    font-weight: 500;
}


/* ── Container Layout ── */
/* ===== 메인 컨테이너 ===== */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

/* 관리자 페이지에서는 container 제한 해제 */
body.admin-page .container {
    max-width: 100%;
    padding: 0;
}

/* ===== 페이지 헤더 ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.5rem;
    margin: 0;
    font-weight: 600;
    color: var(--text);
}

.back-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.85rem;
    display: inline-block;
    margin-bottom: 0.25rem;
}

/* Sticky 페이지 헤더 */
.page-header-sticky {
    position: sticky;
    top: 53px;
    background: var(--bg);
    z-index: 50;
    margin: 0 -1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ── Title Inline Editing ── */
/* 제목 인라인 편집 */
.title-wrapper {
    flex: 1;
}

.title-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.title-display h1 {
    margin: 0;
}

.btn-edit-title {
    background: transparent;
    border: none;
    font-size: 0.9rem;
    opacity: 0.4;
    cursor: pointer;
    padding: 0.25rem;
    min-height: auto;
    transition: opacity 0.15s;
}

.btn-edit-title:hover {
    opacity: 1;
}

/* 편집 모드 */
.title-edit {
    display: none;
}

.title-edit.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

.title-edit-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    max-width: 500px;
}

[data-theme="dark"] .title-edit-card {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.title-input-inline {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    border: none;
    border-bottom: 2px solid var(--primary);
    border-radius: 0;
    background: transparent;
    padding: 0.25rem 0;
    width: 100%;
    margin: 0;
}

.title-input-inline:focus {
    outline: none;
    box-shadow: none;
}

.desc-input-inline {
    font-size: 0.9rem;
    color: var(--text-muted);
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    padding: 0.5rem 0;
    width: 100%;
    margin-top: 0.75rem;
}

.desc-input-inline:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: none;
}

.title-edit-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: flex-end;
}

.btn-save-inline,
.btn-cancel-inline {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    min-height: auto;
}

.btn-save-inline {
    background: var(--primary);
    color: white;
}

.btn-save-inline:hover {
    background: var(--primary-dark);
    transform: scale(1.08);
}

.btn-cancel-inline {
    background: var(--bg-hover);
    color: var(--text-muted);
}

.btn-cancel-inline:hover {
    background: var(--border);
    color: var(--text);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.survey-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0.25rem 0 0 0;
}

/* ── Question Editor (items, likert, options) ── */
/* ===== 문항 목록 ===== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.question-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.question-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
}

/* 문항 복사 시 하이라이트 애니메이션 */
@keyframes questionCopied {
    0% {
        border-color: var(--primary);
        box-shadow: 0 0 0 4px var(--primary-light);
        background: var(--primary-light);
    }
    70% {
        border-color: var(--primary);
        box-shadow: 0 0 0 4px var(--primary-light);
        background: var(--primary-light);
    }
    100% {
        border-color: var(--border);
        box-shadow: none;
        background: var(--bg);
    }
}

.question-item.just-copied {
    animation: questionCopied 1.5s ease-out forwards;
}

.question-item.editing {
    border-color: var(--primary);
    background: var(--bg-card);
}

.question-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.question-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.question-header-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.q-number {
    min-width: 1.5rem;
    height: 1.5rem;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.35rem 0.5rem;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.15s;
    min-height: auto;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.btn-icon.btn-delete:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

.btn-icon.btn-copy {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.btn-add-question {
    width: 100%;
    margin-top: 0.75rem;
    background: transparent;
    border: 2px dashed var(--border);
    color: var(--muted);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-add-question:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* 인라인 편집 UI */
.q-type-select {
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    min-height: auto;
    width: auto;
    margin: 0;
}

.q-required-label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
    cursor: pointer;
}

.q-required-label input {
    width: 14px;
    height: 14px;
    margin: 0;
}

.q-category-select {
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    min-height: auto;
    width: auto;
    max-width: 150px;
    margin: 0;
}

.q-category-select optgroup {
    font-weight: 600;
    color: var(--text-muted);
}

.q-category-select option {
    font-weight: normal;
    color: var(--text);
}

.btn-icon.btn-save {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 500;
}

.btn-icon.btn-save:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.question-body-inline {
    padding: 0.5rem 0 0 0;
}

.q-text-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text);
    margin: 0 0 0.5rem 0;
}

.q-text-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* 인라인 선택지 */
.q-options-inline {
    margin-top: 0.5rem;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.option-inline {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.option-inline input[type="text"] {
    flex: 1;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text);
    margin: 0;
}

.option-inline input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-option-remove {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
    border-radius: 4px;
    min-height: auto;
}

.btn-option-remove:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

.btn-option-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-top: 0.35rem;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 4px;
    color: var(--muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    min-height: auto;
}

.btn-option-add:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* 척도형 WYSIWYG */
.q-likert-inline {
    margin-top: 0.5rem;
}

.likert-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.likert-label-edit {
    border: none;
    border-bottom: 1px dashed var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 0.25rem 0;
    width: 80px;
    text-align: center;
    margin: 0;
}

.likert-label-edit-min { text-align: right; }
.likert-label-edit-max { text-align: left; }

.likert-label-edit:focus {
    outline: none;
    border-color: var(--primary);
}

.likert-scale-preview {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
}

.likert-point {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.likert-point-circle {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card);
}

.likert-point-num {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.likert-range-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* 인라인 텍스트 설정 */
.q-text-settings {
    margin-top: 0.5rem;
}

/* WYSIWYG 텍스트 프리뷰 */
.textarea-preview {
    border: 1px solid var(--border);
    border-radius: 8px;
    min-height: 80px;
    padding: 0.75rem;
    background: var(--input-bg);
}

.textarea-placeholder-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.textarea-placeholder-input {
    border: none;
    background: transparent;
    flex: 1;
    color: var(--text-muted);
    font-size: 16px;
    margin: 0;
    padding: 0;
}

.textarea-placeholder-input::placeholder {
    color: var(--muted);
    opacity: 0.6;
}

.textarea-placeholder-input:focus {
    outline: none;
}

.textarea-maxlength-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.text-settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.char-limit-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.text-settings-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.setting-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.setting-input {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text);
    margin: 0;
}

.setting-input-num {
    width: 50px;
    text-align: center;
}

.drag-handle {
    cursor: grab;
    color: var(--muted);
    padding: 0.25rem;
    font-size: 1.2rem;
    touch-action: none;
}

.q-type {
    font-size: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    color: var(--text-muted);
}

.q-required {
    font-size: 0.7rem;
    color: var(--danger);
    font-weight: 500;
}

.question-body {
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
}

.question-body:hover {
    background: var(--hover-overlay);
}

.q-text {
    margin: 0 0 0.5rem 0;
    font-weight: 500;
    color: var(--text);
}

.q-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.q-option {
    font-size: 0.8rem;
    background: var(--bg-card);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    color: var(--text);
}

.q-option.empty {
    color: var(--muted);
    font-style: italic;
}

.q-likert {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text);
}

.q-likert-range {
    color: var(--muted);
}

.question-footer {
    margin-top: 0.5rem;
    text-align: right;
}

/* 문항 편집 폼 */
.likert-settings,
.choice-settings {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
}

.options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.options-editor {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.option-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.option-row input[type="text"] {
    flex: 1;
    margin: 0;
    padding: 0.5rem 0.75rem;
}

.btn-remove {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.15s;
}

.btn-remove:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

.btn-add-option {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--muted);
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.875rem;
    transition: all 0.15s;
    width: 100%;
    text-align: left;
}

.btn-add-option:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* ── Spinner ── */
.analysis-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 350px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Analysis Page ── */
/* ===== 분석 페이지 ===== */

/* 전폭 레이아웃 */
body.analysis-wide .container {
    max-width: none;
    padding: 0 1rem;
}
body.analysis-wide .header-nav nav {
    max-width: none;
}

/* 컴팩트 툴바 */
.analysis-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 40px;
    padding: 0 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1rem;
    gap: 8px;
}

.analysis-toolbar .toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.analysis-toolbar .back-link {
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: none;
}
.analysis-toolbar .back-link:hover {
    color: var(--primary);
}

.analysis-toolbar .toolbar-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
}

.analysis-toolbar .toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.compare-select {
    font-size: 12px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text);
    cursor: pointer;
}

.compare-label {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* 설정 패널 (수평 3열, 접기 가능) */
.analysis-setup-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 1rem;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.setup-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
}

.setup-panel-header:hover {
    background: var(--bg-hover);
}

.setup-panel-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.setup-toggle-icon {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.3s;
}

.analysis-setup-panel.collapsed .setup-panel-body {
    display: none;
}

.analysis-setup-panel.collapsed .setup-toggle-icon {
    transform: rotate(-90deg);
}

.setup-panel-body {
    padding: 16px;
}

.setup-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr auto;
    gap: 16px;
    align-items: start;
}

.setup-col-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 설문 선택 리스트 */
.survey-select-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.survey-select-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.85rem;
}

.survey-select-item:last-child {
    border-bottom: none;
}

.survey-select-item:hover {
    background: var(--bg-hover);
}

.survey-select-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.survey-select-item input[type="checkbox"] {
    margin-top: 0.2rem;
    width: 16px;
    height: 16px;
}

.survey-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.survey-title {
    font-weight: 500;
    color: var(--text);
    font-size: 0.85rem;
}

.survey-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* 선택된 설문 & 매핑 (설정 패널 내) */
.selected-surveys {
    margin-bottom: 0.75rem;
}

.selected-surveys h4 {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.selected-list {
    min-height: 50px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 0.4rem;
}

.selected-list .empty-message {
    color: var(--text-muted);
    text-align: center;
    padding: 0.75rem;
    margin: 0;
    font-size: 0.85rem;
}

.selected-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.4rem;
    cursor: move;
    font-size: 0.85rem;
}

.selected-item:last-child {
    margin-bottom: 0;
}

.order-num {
    width: 22px;
    height: 22px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    flex-shrink: 0;
}

.survey-name {
    flex: 1;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.2rem;
    line-height: 1;
}

.btn-remove:hover {
    color: var(--danger);
}

.btn-full {
    width: 100%;
}

/* 매핑 섹션 */
.mapping-section-inline {
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

.mapping-section-inline h5 {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.mapping-group {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
}

.mapping-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.mapping-name {
    flex: 1;
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.8rem;
}

.mapping-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.mapping-tag {
    background: var(--bg-hover);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* 분석 실행 버튼 영역 */
.setup-action-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 100px;
}

.setup-action-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* 분석 결과 플레이스홀더 */
.analysis-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 350px;
    text-align: center;
    color: var(--text-muted);
}

.placeholder-icon {
    font-size: 3.5rem;
    margin-bottom: 0.75rem;
}

.analysis-placeholder h3 {
    color: var(--text);
    margin-bottom: 0.5rem;
}

/* 로딩 */
.analysis-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 350px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* KPI 스트립 */
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
}

.kpi-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.kpi-sub {
    font-size: 0.8rem;
    margin-top: 0.3rem;
}

.kpi-positive {
    color: #22c55e;
}
[data-theme="dark"] .kpi-positive {
    color: #4ade80;
}

.kpi-negative {
    color: #ef4444;
}
[data-theme="dark"] .kpi-negative {
    color: #f87171;
}

.kpi-neutral {
    color: var(--text-muted);
}

/* KPI 등급 배지 */
.kpi-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 6px;
    vertical-align: middle;
}

.kpi-badge.tier-excellent { background: rgba(34,197,94,0.12); color: #16a34a; }
.kpi-badge.tier-good { background: rgba(59,130,246,0.12); color: #2563eb; }
.kpi-badge.tier-caution { background: rgba(245,158,11,0.12); color: #d97706; }
.kpi-badge.tier-danger { background: rgba(239,68,68,0.12); color: #dc2626; }

[data-theme="dark"] .kpi-badge.tier-excellent { background: rgba(34,197,94,0.18); color: #4ade80; }
[data-theme="dark"] .kpi-badge.tier-good { background: rgba(59,130,246,0.18); color: #60a5fa; }
[data-theme="dark"] .kpi-badge.tier-caution { background: rgba(245,158,11,0.18); color: #fbbf24; }
[data-theme="dark"] .kpi-badge.tier-danger { background: rgba(239,68,68,0.18); color: #f87171; }

/* KPI 진행률 바 */
.kpi-bar-wrap {
    margin-top: 8px;
    height: 6px;
    background: var(--bg-hover);
    border-radius: 3px;
    overflow: hidden;
}

.kpi-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.kpi-bar.tier-excellent { background: #22c55e; }
.kpi-bar.tier-good { background: #3b82f6; }
.kpi-bar.tier-caution { background: #f59e0b; }
.kpi-bar.tier-danger { background: #ef4444; }

/* KPI 스파크라인 */
.kpi-spark {
    margin-top: 6px;
    height: 28px;
}

.kpi-spark canvas {
    width: 100%;
    height: 100%;
}

/* KPI 경고 태그 */
.kpi-alert-tag {
    display: inline-block;
    margin-top: 4px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    background: rgba(245,158,11,0.12);
    color: #d97706;
}
[data-theme="dark"] .kpi-alert-tag {
    background: rgba(245,158,11,0.18);
    color: #fbbf24;
}

/* 차트 섹션 */
.analysis-chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.chart-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

.chart-header-bar h3 {
    font-size: 0.9rem;
    margin: 0;
    color: var(--text);
}

.chart-controls {
    display: flex;
    gap: 4px;
}

.chart-ctrl-btn {
    font-size: 11px;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.chart-ctrl-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.chart-ctrl-btn:hover:not(.active) {
    background: var(--bg-hover);
}

.chart-body {
    padding: 16px;
}

.chart-wrapper {
    height: 380px;
    position: relative;
}

/* 테이블 섹션 */
.analysis-table-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.table-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

.table-header-bar h3 {
    font-size: 0.9rem;
    margin: 0;
    color: var(--text);
}

.btn-csv {
    font-size: 11px;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-csv:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.table-body-wrap {
    padding: 0;
    overflow-x: auto;
}

/* 상세 테이블 */
.table-responsive {
    overflow-x: auto;
}

.analysis-table.enhanced {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.analysis-table.enhanced th,
.analysis-table.enhanced td {
    padding: 0.6rem 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.analysis-table.enhanced th {
    background: var(--bg-hover);
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
}

.analysis-table.enhanced th.sub-date {
    font-weight: 400;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.analysis-table.enhanced th:first-child,
.analysis-table.enhanced td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 1;
}

.analysis-table.enhanced thead th:first-child {
    background: var(--bg-hover);
}

/* 등급별 좌측 보더 */
.analysis-table.enhanced tr.tier-excellent td:first-child { border-left: 3px solid #22c55e; }
.analysis-table.enhanced tr.tier-good td:first-child { border-left: 3px solid #3b82f6; }
.analysis-table.enhanced tr.tier-caution td:first-child { border-left: 3px solid #f59e0b; }
.analysis-table.enhanced tr.tier-danger td:first-child { border-left: 3px solid #ef4444; }

.category-name {
    font-weight: 500;
}

/* 점수 셀 내 비율바 */
.score-cell-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.score-val {
    font-family: monospace;
    font-weight: 500;
}

.score-bar-mini {
    width: 100%;
    max-width: 60px;
    height: 4px;
    background: var(--bg-hover);
    border-radius: 2px;
    overflow: hidden;
}

.score-bar-mini-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.4s ease;
}

.score-bar-mini-fill.tier-excellent { background: #22c55e; }
.score-bar-mini-fill.tier-good { background: #3b82f6; }
.score-bar-mini-fill.tier-caution { background: #f59e0b; }
.score-bar-mini-fill.tier-danger { background: #ef4444; }

.score-cell.no-data {
    color: var(--text-muted);
}

/* 변화 셀 */
.change-cell {
    font-weight: 600;
    font-size: 0.85rem;
}

.change-cell.positive { color: #22c55e; }
.change-cell.negative { color: #ef4444; }
.change-cell.neutral { color: var(--text-muted); }

[data-theme="dark"] .change-cell.positive { color: #4ade80; }
[data-theme="dark"] .change-cell.negative { color: #f87171; }

/* 스파크라인 열 */
.td-sparkline {
    width: 80px;
    min-width: 80px;
}

.td-sparkline canvas {
    display: block;
    width: 70px;
    height: 24px;
    margin: 0 auto;
}

/* 행 하이라이트 */
.analysis-table.enhanced tr.row-highlight {
    background: var(--primary-light);
    transition: background 0.3s;
}

/* 비교 대상 컬럼 하이라이트 */
.analysis-table.enhanced th.compare-highlight,
.analysis-table.enhanced td.compare-highlight {
    background: rgba(59,130,246,0.06);
}

[data-theme="dark"] .analysis-table.enhanced th.compare-highlight,
[data-theme="dark"] .analysis-table.enhanced td.compare-highlight {
    background: rgba(59,130,246,0.1);
}


/* ── Report & Stats Table ── */
/* ===== 리포트 스타일 ===== */

/* 리포트 컨테이너 */
.report-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* 리포트 헤더 */
.report-header {
    padding: 1.5rem;
}

.report-title-section {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.report-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.75rem 0;
}

.report-insight {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.6;
}

.report-insight strong {
    color: var(--text);
}

/* 요약 메트릭 그리드 */
.report-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.summary-metric {
    background: var(--bg);
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.summary-metric:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.summary-metric.best {
    border-color: var(--primary);
    background: var(--primary-light);
}

.summary-metric.worst {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.metric-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.metric-category {
    display: block;
    font-size: 0.85rem;
    color: var(--text);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.metric-value {
    display: block;
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.summary-metric.best .metric-value {
    color: var(--primary);
}

.summary-metric.worst .metric-value {
    color: var(--danger);
}

.metric-detail {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* 차트 섹션 */
.report-chart {
    padding: 1.5rem;
}

.report-chart h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.chart-hint {
    margin: 0 0 1rem 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.report-chart .chart-wrapper {
    height: 400px;
    position: relative;
}

/* 통계 테이블 섹션 */
.report-table {
    padding: 1.5rem;
}

.report-table h3 {
    margin: 0 0 1.5rem 0;
    font-size: 1.1rem;
    font-weight: 600;
}

/* 카테고리 섹션 */
.category-section {
    margin-bottom: 2rem;
}

.category-section:last-child {
    margin-bottom: 0;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

.category-badge {
    background: var(--primary);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.category-avg {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* 통계 테이블 */
.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.stats-table th,
.stats-table td {
    padding: 0.75rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.stats-table th.stat-header {
    background: var(--bg);
    font-weight: 600;
    color: var(--text-muted);
    width: 80px;
    text-align: left;
}

.stats-table th.question-header {
    background: var(--bg);
    font-weight: 500;
    color: var(--text);
    min-width: 100px;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8rem;
}

.stats-table td.stat-name {
    font-weight: 500;
    color: var(--text-muted);
    text-align: left;
    background: var(--bg);
}

.stats-table td.stat-value {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    color: var(--text);
    font-size: 0.9rem;
}

.stats-table td.stat-value.best {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
}

.stats-table td.stat-value.worst {
    background: var(--danger-bg);
    color: var(--danger);
    font-weight: 700;
}

/* ===== Tabulator 미니멀 스타일 ===== */
#stats-table {
    margin-top: 1rem;
}

/* 테이블 컨테이너 */
#stats-table .tabulator {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    box-shadow: none;
    overflow: hidden;
}

/* 헤더 영역 */
#stats-table .tabulator-header {
    background: transparent;
    border-bottom: none;
}

#stats-table .tabulator-headers {
    background: var(--bg);
}

/* 대분류 헤더 - 중립적 회색 */
#stats-table .tabulator-col-group > .tabulator-col-content {
    background: var(--bg) !important;
    color: var(--text) !important;
    font-weight: 600;
    font-size: 0.8rem;
    text-align: center;
    padding: 0.7rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* 대분류 구분선 */
#stats-table .tabulator-col-group {
    border-right: 1px solid var(--border);
}

#stats-table .tabulator-col-group:last-child {
    border-right: none;
}

/* 소분류 헤더 */
#stats-table .tabulator-col-group .tabulator-col .tabulator-col-content {
    background: var(--bg-card) !important;
    color: var(--text-muted) !important;
    font-weight: 500;
    font-size: 0.7rem;
    text-align: center;
    padding: 0.5rem 0.4rem;
    border-top: 1px solid var(--border);
}

/* 고정 열 (구분) 헤더 */
#stats-table .tabulator-frozen .tabulator-col-content {
    background: var(--bg) !important;
    color: var(--text-muted) !important;
    font-weight: 600;
    font-size: 0.75rem;
}

/* 고정 열 (구분) 데이터 셀 */
#stats-table .tabulator-frozen.tabulator-cell {
    background: var(--bg) !important;
    font-weight: 500;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
}

/* 데이터 셀 */
#stats-table .tabulator-cell {
    padding: 0.55rem 0.6rem;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.8rem;
    text-align: center;
    border-right: none;
}

/* 행 스타일 */
#stats-table .tabulator-row {
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

#stats-table .tabulator-row:last-child {
    border-bottom: none;
}

#stats-table .tabulator-row:hover {
    background: var(--bg-hover) !important;
}

/* 홀수/짝수 행 교차 */
#stats-table .tabulator-row:nth-child(even) {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] #stats-table .tabulator-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

#stats-table .tabulator-row:nth-child(even):hover {
    background: var(--bg-hover) !important;
}

/* 테이블 홀더 */
#stats-table .tabulator-tableholder {
    background: var(--bg-card);
}

/* 리포트 통계 섹션 */
.report-stats {
    padding: 1.5rem;
}

.report-stats h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.report-stats .chart-wrapper {
    height: 300px;
    margin-bottom: 1.5rem;
}

/* 테이블 반응형 스크롤 */
.table-responsive {
    overflow-x: auto;
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
}

/* Legacy 통계 섹션 */
.legacy-stats {
    margin-top: 2rem;
}

.legacy-stats .section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: var(--text);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

/* 인쇄 스타일 */
@media print {
    .header-nav,
    .filter-card,
    .action-buttons,
    .legacy-stats,
    .dashboard-header-right {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
    }

    .report-container {
        background: white !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }

    .category-section {
        break-inside: avoid;
    }

    .report-chart .chart-wrapper {
        height: 350px !important;
    }

    .summary-metric {
        border: 1px solid #ddd !important;
    }

    .summary-metric.best {
        background: #e6f2ff !important;
    }

    .summary-metric.worst {
        background: #ffe6e6 !important;
    }
}

/* 리포트 반응형 */
@media (max-width: 768px) {
    .report-summary-grid {
        grid-template-columns: 1fr;
    }

    .metric-value {
        font-size: 1.75rem;
    }

    .category-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .stats-table {
        font-size: 0.75rem;
    }

    .stats-table th,
    .stats-table td {
        padding: 0.5rem 0.25rem;
    }

    .stats-table th.stat-header {
        width: 60px;
    }

    .report-chart .chart-wrapper {
        height: 300px;
    }
}

/* 다크 테마 조정 */
[data-theme="dark"] .summary-metric.best {
    background: rgba(26, 115, 232, 0.15);
}

[data-theme="dark"] .summary-metric.worst {
    background: rgba(220, 53, 69, 0.15);
}

[data-theme="dark"] .stats-table td.stat-value.best {
    background: rgba(26, 115, 232, 0.2);
}

[data-theme="dark"] .stats-table td.stat-value.worst {
    background: rgba(220, 53, 69, 0.2);
}

/* ── Results Dashboard v2/v4 ── */
/* ===== 결과 대시보드 v2 (산업용 2패널) ===== */

/* 풀스크린 컨테이너 */
body.results-wide .container {
    max-width: none;
    padding: 0;
}

body.results-wide .header-nav nav {
    max-width: none;
}

/* v2 대시보드 루트 */
.results-dashboard-v2 {
    font-size: 11px;
    padding: 0;
}

/* ── 날짜 필터 (df-*) ── */
/* df-presets, df-chip 등은 filter-view-bar 내에서 계속 사용됨 */
.df-presets {
    display: flex;
    gap: 4px;
    align-items: center;
}

.df-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.df-chip:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.df-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.df-manual-row {
    display: flex;
    align-items: center;
    gap: 5px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
}

.df-date-input {
    padding: 3px 6px;
    font-size: 12px;
    height: 26px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text);
    width: 130px;
}

.df-sep {
    color: var(--text-muted);
    font-size: 12px;
}

.df-apply-btn {
    padding: 3px 10px;
    height: 26px;
    font-size: 11px;
    font-weight: 600;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.df-apply-btn:hover {
    background: var(--primary-dark);
}

.df-status-text {
    font-size: 11px;
    color: var(--text-muted);
}

.df-reset-btn {
    font-size: 10px;
    padding: 2px 7px;
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.df-reset-btn:hover {
    background: var(--danger-bg);
}

.df-table-wrap {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.df-table-wrap .tabulator {
    font-size: 11px;
    border: none;
}

.df-table-wrap .tabulator .tabulator-header {
    font-size: 10px;
}

.df-table-wrap .tabulator .tabulator-tableholder {
    overflow-x: auto;
}

.df-label-col {
    font-weight: 600;
    background: var(--surface, var(--bg-card)) !important;
}

.df-total-col {
    font-weight: 700;
    background: var(--surface, var(--bg-card)) !important;
}

.df-legend {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.df-gran-chip {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    font-size: 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    line-height: 1.4;
}

.df-gran-chip:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--text);
}

.df-gran-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    padding: 2px 6px;
    min-height: 22px;
    height: 22px;
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    font-weight: 500;
}

.toolbar-btn:hover {
    background: var(--border);
}

.toolbar-actions {
    display: flex;
    gap: 3px;
}

/* 내보내기 드롭다운 */
.export-dropdown {
    position: relative;
}

.export-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 2px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: var(--shadow);
    min-width: 120px;
    z-index: 200;
    overflow: hidden;
}

.export-menu.show {
    display: block;
}

.export-menu a,
.export-menu button {
    display: block;
    width: 100%;
    padding: 6px 10px;
    font-size: 11px;
    color: var(--text);
    text-decoration: none;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    min-height: auto;
    border-radius: 0;
}

.export-menu a:hover,
.export-menu button:hover {
    background: var(--bg-hover);
}

/* ── 2패널 레이아웃 ── */
.dashboard-panels {
    display: grid;
    grid-template-columns: 14rem 1fr;
    height: calc(100vh - 3.3125rem - 1rem);
    overflow: hidden;
}

/* ── 좌측 패널 ── */
.left-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
}

/* ── 리사이즈 핸들 ── */
.resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    width: 4px;
    height: 100%;
    cursor: col-resize;
    z-index: 10;
    transition: background 0.15s;
}
.resize-handle:hover,
.resize-handle.active {
    background: var(--border);
}

.left-panel-section {
    padding: 0.375rem;
    border-bottom: 1px solid var(--border);
}

.panel-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

/* 카테고리 히트맵 (v3: canvas → HTML 인라인 바) */
.category-heatmap {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.heatmap-row {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 18px;
}

.heatmap-label {
    font-size: 0.6875rem;
    width: 52px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
    color: var(--text);
}

.heatmap-bar-wrap {
    flex: 1;
    height: 10px;
    background: var(--bg);
    border-radius: 2px;
    overflow: hidden;
}

.heatmap-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}

.heatmap-bar.hm-high {
    background: var(--primary);
}

.heatmap-bar.hm-mid {
    background: #9ca3af;
}

.heatmap-bar.hm-low {
    background: var(--danger);
}

.heatmap-val {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.6875rem;
    font-weight: 600;
    width: 28px;
    text-align: right;
    flex-shrink: 0;
    color: var(--text-muted);
}

/* 문항 인덱스 */
.question-index {
    flex: 1;
    min-height: 0;
}

.question-index-list {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: calc(100vh - 53px - 28px - 120px);
}

.question-index-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    height: 22px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.75rem;
    border-bottom: 1px solid transparent;
    transition: background 0.1s;
    cursor: pointer;
}

.question-index-row:hover {
    background: var(--bg-hover);
}

.question-index-row.qi-other {
    opacity: 0.6;
}

.qi-num {
    width: 18px;
    height: 18px;
    background: var(--bg-hover);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 600;
    flex-shrink: 0;
    color: var(--text-muted);
}

.qi-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.75rem;
}

.qi-val {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
}

.qi-val.qi-high {
    color: var(--primary);
}

.qi-val.qi-low {
    color: var(--danger);
}

/* ── 우측 패널 ── */
.right-panel {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg);
    gap: 1px;
}

/* 차트 행 (2개 가로) */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 1px;
    background: var(--border);
    flex-shrink: 0;
}

.chart-cell {
    background: var(--bg-card);
    padding: 8px;
}

.cell-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.chart-wrap-sm {
    height: 200px;
    position: relative;
}

/* v3: 세부항목 차트 (full-width, 140px) */
.chart-section {
    background: var(--bg-card);
    padding: 0.375rem;
    flex-shrink: 0;
}

.chart-wrap-detail {
    height: 8.125rem;
    position: relative;
}

/* ── 문항 상세 패널 (항상 표시) ── */
.question-details-panel {
    background: var(--bg-card);
    padding: 0.25rem;
}

.question-details-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.1875rem;
    margin-top: 0.25rem;
}

/* 타입별 섹션 라벨 */
.qd-section-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0.75rem 0 0.25rem 0;
    padding-left: 0.125rem;
}

.qd-section-label:first-of-type {
    margin-top: 0.25rem;
}

/* 선택형: 2컬럼 */
.question-details-grid--choice {
    grid-template-columns: repeat(2, 1fr);
}

.question-details-grid--likert {
    grid-template-columns: repeat(3, 1fr);
}

/* 서술형: 1컬럼 */
.question-details-grid--text {
    grid-template-columns: 1fr;
}

/* 컴팩트 문항 카드 */
.qcard {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    padding: 0.1875rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.qcard-full {
    grid-column: 1 / -1;
}

.qcard-header {
    display: flex;
    align-items: center;
    gap: 0.1875rem;
    margin-bottom: 0.1875rem;
}

.qcard-num {
    width: 1.25rem;
    height: 1.25rem;
    background: var(--muted);
    color: white;
    border-radius: 0.1875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 600;
    flex-shrink: 0;
}

.qcard-text {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.qcard-count {
    font-size: 0.8125rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* 리커트 문항 카드 */
.qcard-likert {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.qcard-avg {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.qcard-dist {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.qcard-dist-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.qcard-dist-label {
    font-size: 0.875rem;
    width: 0.8125rem;
    text-align: right;
    color: var(--text-muted);
    flex-shrink: 0;
}

.qcard-dist-bar-wrap {
    flex: 1;
    height: 0.5rem;
    background: var(--bg-card);
    border-radius: 2px;
    overflow: hidden;
}

.qcard-dist-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
}

.qcard-dist-count {
    font-size: 0.8125rem;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 3rem;
    text-align: right;
}

.qcard-dist-pct {
    margin-left: 0.125rem;
    opacity: 0.7;
}

/* 선택형 문항 카드 */
.qcard-options {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.qcard-opt-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    height: 1rem;
}

.qopt-label {
    font-size: 0.875rem;
    width: 5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
    color: var(--text);
}

.qopt-bar-wrap {
    flex: 1;
    height: 0.5rem;
    background: var(--bg-card);
    border-radius: 2px;
    overflow: hidden;
}

.qopt-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
}

.qopt-count {
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 3.75rem;
    text-align: right;
}

/* 텍스트형 문항 카드 */
.qcard-text-responses ul {
    list-style: disc;
    padding-left: 14px;
    margin: 0;
    font-size: 0.875rem;
    color: var(--text);
}

.qcard-text-responses li {
    margin-bottom: 2px;
    line-height: 1.3;
}

.qcard-more {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 2px 0 0 0;
}

.qcard-empty {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
    margin: 0;
}

/* 하이라이트 애니메이션 */
@keyframes qcardHighlight {
    0% {
        border-color: var(--primary);
        box-shadow: 0 0 0 2px var(--primary-light);
    }
    70% {
        border-color: var(--primary);
        box-shadow: 0 0 0 2px var(--primary-light);
    }
    100% {
        border-color: var(--border);
        box-shadow: none;
    }
}

.qcard-highlight {
    animation: qcardHighlight 1.5s ease-out forwards;
}

/* ===== 결과 대시보드 v2 반응형 ===== */

@media (max-width: 1200px) {
    .dashboard-panels {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .left-panel {
        display: none;
    }

    .chart-wrap-detail {
        height: 160px;
    }

    .question-details-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .question-details-grid--likert {
        grid-template-columns: repeat(2, 1fr);
    }

}

@media (max-width: 768px) {
    .question-details-grid,
    .question-details-grid--choice,
    .question-details-grid--likert {
        grid-template-columns: 1fr;
    }

    /* 날짜 필터 (모바일) */
    .df-manual-row {
        padding-left: 0;
        border-left: none;
    }

    .filter-status-inline {
        padding-left: 0;
        border-left: none;
    }
}

/* 인쇄 스타일 */
@media print {
    .dashboard-panels {
        height: auto;
        overflow: visible;
        grid-template-columns: 1fr;
    }

    .left-panel {
        display: none;
    }

    .context-bar-right .export-dropdown {
        display: none !important;
    }

    .filter-view-bar {
        display: none !important;
    }

    .date-table-section {
        display: none !important;
    }

    .right-panel {
        overflow: visible;
    }

    .qcard {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .chart-section,
    .question-details-panel {
        break-inside: avoid;
    }
}

/* ===== 결과 대시보드 v4 (Insight-First) ===== */

/* ── 인사이트 스트립 ── */
.insight-strip {
    display: flex;
    gap: 0.25rem;
    padding: 0.375rem;
    overflow-x: auto;
    background: var(--bg-card);
    flex-shrink: 0;
    scrollbar-width: thin;
}

.insight-strip::-webkit-scrollbar {
    height: 4px;
}

.insight-strip::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.insight-card {
    flex-shrink: 0;
    min-width: 11.25rem;
    max-width: 300px;
    padding: 6px 10px;
    border-radius: 6px;
    border-left: 3px solid var(--muted);
    background: var(--bg);
    font-size: 0.75rem;
    line-height: 1.4;
}

.insight-card-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.insight-card-desc {
    color: var(--text-muted);
    font-size: 0.6875rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.insight-weakness { border-left-color: #ef4444; }
.insight-strength { border-left-color: #22c55e; }
.insight-split { border-left-color: #f59e0b; }
.insight-dept_gap { border-left-color: #8b5cf6; }

/* ── 등급 유틸리티 ── */
.tier-excellent { background: rgba(34,197,94,0.12) !important; color: #16a34a !important; }
.tier-good { background: rgba(59,130,246,0.12) !important; color: #2563eb !important; }
.tier-caution { background: rgba(245,158,11,0.12) !important; color: #d97706 !important; }
.tier-danger { background: rgba(239,68,68,0.12) !important; color: #dc2626 !important; }

[data-theme="dark"] .tier-excellent { background: rgba(34,197,94,0.18) !important; color: #4ade80 !important; }
[data-theme="dark"] .tier-good { background: rgba(59,130,246,0.18) !important; color: #60a5fa !important; }
[data-theme="dark"] .tier-caution { background: rgba(245,158,11,0.18) !important; color: #fbbf24 !important; }
[data-theme="dark"] .tier-danger { background: rgba(239,68,68,0.18) !important; color: #f87171 !important; }

/* ── 사이드바 인덱스 그룹 헤더 ── */
.qi-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px 2px 6px;
    margin-top: 2px;
    border-top: 1px solid var(--border);
    background: var(--bg-hover);
}

.qi-group-header:first-child {
    margin-top: 0;
    border-top: none;
}

.qi-group-name {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.qi-group-avg {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 4px;
}

/* ── 사이드바 인덱스 등급 도트 ── */
.qi-tier-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Charts Row (레이더 + 등급밴드 막대차트) ── */
.charts-row-v4 {
    display: grid;
    grid-template-columns: 18rem 1fr;
    gap: 1px;
    background: var(--border);
    flex-shrink: 0;
}

.charts-row-v4 .chart-cell {
    background: var(--bg-card);
    padding: 0.375rem;
}

.chart-wrap-radar {
    height: 11.25rem;
    position: relative;
}

/* ── 부서별 히트맵 ── */
.dept-heatmap-section {
    background: var(--bg-card);
    padding: 0.375rem;
    flex-shrink: 0;
}

.dept-heatmap-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

.dept-heatmap-table th,
.dept-heatmap-table td {
    padding: 0.25rem 0.5rem;
    text-align: center;
    border: 1px solid var(--border);
}

.dept-heatmap-table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.dept-heatmap-table td:first-child {
    text-align: left;
    font-weight: 500;
    color: var(--text);
    background: var(--bg);
    font-family: inherit;
}

.dept-hm-cell {
    border-radius: 3px;
    font-weight: 600;
    min-width: 48px;
}

.dept-count {
    font-size: 0.625rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ── 의견분리 배지 ── */
.qcard-bimodal-badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(245,158,11,0.15);
    color: #d97706;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

[data-theme="dark"] .qcard-bimodal-badge {
    background: rgba(245,158,11,0.2);
    color: #fbbf24;
}

/* ── 반응형 v4 ── */
@media (max-width: 1200px) {
    .charts-row-v4 {
        grid-template-columns: 1fr;
    }
}

@media print {
    .insight-strip {
        flex-wrap: wrap;
        overflow: visible;
    }
    .dept-heatmap-section {
        break-inside: avoid;
    }
}

/* ── VoC Selector ── */
/* ===== VoC 카테고리 - 응답자 칩 UI ===== */
.voc-selector {
    position: relative;
    margin-bottom: 1rem;
    padding: 1rem 1rem 1rem 1.25rem;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.voc-selector::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
    border-radius: 8px 0 0 8px;
    opacity: 0.4;
}

.voc-selector.voc-error {
    border-color: var(--danger);
    animation: vocShake 0.3s ease;
}

.voc-selector.voc-error::before {
    background: var(--danger);
    opacity: 0.8;
}

@keyframes vocShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.voc-prompt {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 600;
}

.voc-level {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    animation: vocLevelIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.voc-level:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

@keyframes vocLevelIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.voc-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.voc-chip:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.voc-chip:active {
    transform: scale(0.97);
    box-shadow: none;
}

.voc-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
}

.voc-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--primary-light);
    border-radius: 6px;
    font-size: 0.85rem;
    animation: vocLevelIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.voc-breadcrumb-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--primary);
    opacity: 0.7;
}

.voc-breadcrumb-text {
    flex: 1;
    color: var(--primary);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.voc-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.voc-reset-btn svg {
    width: 12px;
    height: 12px;
}

.voc-reset-btn:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* ===== VoC 관리자 - 문항 편집 토글 ===== */
.q-voc-settings {
    border: 1px solid var(--border);
    border-top: 1px dotted var(--border);
    border-radius: 0 0 6px 6px;
    margin-top: -1px;
}

.voc-toggle-row {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem;
    align-items: center;
}

.voc-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.voc-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
}

.voc-toggle-label input[type="checkbox"] {
    margin: 0;
    width: auto;
}

/* ===== VoC 관리자 - 셋 선택 (설문 편집) ===== */
.voc-set-select-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.voc-set-label-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.voc-set-label-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.voc-set-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.voc-set-select-row select {
    flex: 1;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.voc-set-select-row select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}


/* ===== VoC 다크 테마 보정 ===== */
[data-theme="dark"] .voc-chip.active {
    box-shadow: 0 2px 8px rgba(77, 163, 255, 0.25);
}

/* ===== VoC 반응형 ===== */
@media (max-width: 600px) {
    .voc-chip {
        padding: 0.35rem 0.75rem;
        font-size: 0.8rem;
    }
    .voc-set-select-row {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ── Modal Dialog ── */
.modal {
    border: none;
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    background: var(--bg-card);
    color: var(--text);
}

.modal::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.modal h3 {
    margin-top: 0;
    margin-bottom: 1rem;
}

.modal input[type="text"] {
    width: 100%;
    margin-bottom: 1rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}
