/* ─── V2 Skeleton Loading ────────────────────────────────── */
.v2-skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: v2Shimmer 1.5s ease-in-out infinite;
    border-radius: 0.75rem;
    min-height: 120px;
    border: 2px solid transparent;
}
.dark .v2-skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
}
@keyframes v2Shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── V2 Retry Button ────────────────────────────────────── */
.v2-retry-btn {
    padding: 4px 14px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    cursor: pointer;
    color: #64748b;
    background: transparent;
    transition: all 0.15s ease;
}
.v2-retry-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
    color: #3b82f6;
}
.dark .v2-retry-btn {
    border-color: #475569;
    color: #94a3b8;
}
.dark .v2-retry-btn:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
    color: #60a5fa;
}

/* ─── V2 Server Focus Highlight ──────────────────────────── */
.v2-server-focused {
    outline: 2px solid #3b82f6 !important;
    outline-offset: -2px;
    background-color: rgba(59, 130, 246, 0.08) !important;
    border-radius: 0.5rem;
    transition: outline 0.15s ease, background-color 0.15s ease;
}
.dark .v2-server-focused {
    background-color: rgba(59, 130, 246, 0.12) !important;
}

/* ─── V2 Tab Bar ───────────────────────────────────────── */
.v2-tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}
.v2-tab:hover {
    background: #f1f5f9;
    color: #334155;
}
.v2-tab.active {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
    font-weight: 600;
}
.dark .v2-tab {
    color: #94a3b8;
}
.dark .v2-tab:hover {
    background: #334155;
    color: #e2e8f0;
}
.dark .v2-tab.active {
    background: rgba(37, 99, 235, 0.15);
    color: #60a5fa;
    border-color: rgba(37, 99, 235, 0.3);
}
.v2-tab-add {
    padding: 4px 8px;
    opacity: 0.5;
}
.v2-tab-add:hover {
    opacity: 1;
}
.v2-tab-actions {
    display: none;
    gap: 2px;
    margin-left: 2px;
}
.v2-tab:hover .v2-tab-actions {
    display: inline-flex;
}
.v2-tab-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    border-radius: 3px;
    opacity: 0.5;
    transition: all 0.1s ease;
}
.v2-tab-action:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.08);
}
.dark .v2-tab-action:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ─── V2 Export Dropdown ────────────────────────────────── */
.v2-export-dropdown {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 4px;
    min-width: 140px;
}
.dark .v2-export-dropdown {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.v2-export-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 10px;
    font-size: 12px;
    color: #475569;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.v2-export-option:hover {
    background: #f1f5f9;
}
.dark .v2-export-option {
    color: #cbd5e1;
}
.dark .v2-export-option:hover {
    background: #334155;
}

/* ─── V2 Freshness Indicator animations ────────��─────────── */
.v2-pulse-live {
    animation: v2PulseLive 2s ease-in-out infinite;
}
.v2-pulse-ping {
    animation: v2PulsePing 0.6s ease-out;
}
@keyframes v2PulseLive {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
@keyframes v2PulsePing {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
    70% { transform: scale(1.3); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ─── V2 Widget Grid System (4-column colspan) ──────────── */

/* Widget grid container — hidden by default, activated by widgetRenderer.js */
.v2-widget-grid {
    display: none;
    width: 100%;
    overflow: hidden;
}

/* Active grid: always 4-column; widgets control their own span */
.v2-widget-grid--active {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: auto;
    grid-auto-flow: row;
    gap: 0.75rem;
    padding: 0.75rem;
    align-items: start;
}

/* ─── Widget colspan classes ─────────────────────────────── */
.v2-col-span-1 { grid-column: span 1; }
.v2-col-span-2 { grid-column: span 2; }
.v2-col-span-3 { grid-column: span 3; }
.v2-col-span-4 { grid-column: span 4; }

/* ─── Widget rowspan classes ─────────────────────────────── */
.v2-row-span-1 { grid-row: span 1; }
.v2-row-span-2 { grid-row: span 2; align-self: stretch; }
.v2-row-span-3 { grid-row: span 3; align-self: stretch; }
.v2-row-span-4 { grid-row: span 4; align-self: stretch; }
.v2-row-span-5 { grid-row: span 5; align-self: stretch; }
.v2-row-span-6 { grid-row: span 6; align-self: stretch; }

/* Rowspan 높이 제어 — 기본 카드는 max-height 제한, rowspan 카드는 확장 */
.v2-widget-card:not(.v2-row-span-2):not(.v2-row-span-3):not(.v2-row-span-4):not(.v2-row-span-5):not(.v2-row-span-6) {
    max-height: 350px;
    overflow-y: auto;
}
.v2-widget-card.v2-row-span-2 { min-height: 500px; max-height: none; }
.v2-widget-card.v2-row-span-3 { min-height: 750px; max-height: none; }
.v2-widget-card.v2-row-span-4 { min-height: 1000px; max-height: none; }
.v2-widget-card.v2-row-span-5 { min-height: 1250px; max-height: none; }
.v2-widget-card.v2-row-span-6 { min-height: 1500px; max-height: none; }

/* Rowspan 카드 내부 콘텐츠 stretch */
.v2-widget-card.v2-row-span-2 > *,
.v2-widget-card.v2-row-span-3 > *,
.v2-widget-card.v2-row-span-4 > *,
.v2-widget-card.v2-row-span-5 > *,
.v2-widget-card.v2-row-span-6 > * {
    flex: 1;
    min-height: 0;
}

/* Rowspan 카드 내부 스크롤 영역 max-height 오버라이드 */
.v2-widget-card.v2-row-span-2 .overflow-y-auto,
.v2-widget-card.v2-row-span-3 .overflow-y-auto,
.v2-widget-card.v2-row-span-4 .overflow-y-auto,
.v2-widget-card.v2-row-span-5 .overflow-y-auto,
.v2-widget-card.v2-row-span-6 .overflow-y-auto {
    max-height: none !important;
}

/* Widget card base styles */
.v2-widget-card {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    overflow-y: auto;
    background: white;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
}

/* Dark mode card (앱 .dark 클래스 기준 — OS prefers-color-scheme 독립) */
.dark .v2-widget-card {
    background: #1e293b;
    border-color: #334155;
}

/* ─── Widget type-specific min-heights ─────────────────────── */
/* rowspan으로 높이를 제어하므로, 위젯별 min-height는 제거.
   대신 grid-auto-rows가 행 최소 높이를 보장한다. */

/* ─── V2 Kiosk Mode ──────────────────────────────────────── */

/* V2 활성 시: V1 요약바·히어로 항상 숨김 (위젯으로 대체) */
body.v2-widget-active #summary-bar,
body.v2-widget-active #hero-summary-toggle {
    display: none !important;
}

/* V2 활성 + 2D 모드: V1 view-container 숨김, 위젯 그리드가 공간 차지 */
body.v2-widget-active #main-view-container:not(.view-mode-3d) .view-container {
    display: none !important;
}

/* V2 활성 + 3D 모드: 위젯 그리드·필터바 숨김, 3D 뷰어 표시 */
body.v2-widget-active #main-view-container.view-mode-3d .v2-widget-grid {
    display: none !important;
}
body.v2-widget-active #main-view-container.view-mode-3d #v2-filter-bar {
    display: none !important;
}
/* 3D 모드: view-container 확실히 표시 + 전체 공간 차지 */
body.v2-widget-active #main-view-container.view-mode-3d .view-container {
    display: block !important;
    flex: 1;
}
/* V1 #view-2d는 .view-mode-3d에서 이미 CSS로 숨겨짐 (dashboard.css) */

/* V2 Kiosk: 6열 그리드, 한 페이지 고정 없음 — 자연 스크롤 */
body.kiosk-mode.v2-widget-active .v2-widget-grid--active,
body.kiosk-v2-active.v2-widget-active .v2-widget-grid--active {
    gap: 0.375rem;
    padding: 0.375rem;
    grid-template-columns: repeat(6, 1fr) !important;
}

/* 2026-06-08: Kiosk V2 colspan 비례 리매핑 (4열→6열) */
body.kiosk-mode .v2-col-span-4, body.kiosk-v2-active .v2-col-span-4 { grid-column: span 6; }
body.kiosk-mode .v2-col-span-3, body.kiosk-v2-active .v2-col-span-3 { grid-column: span 4; }
body.kiosk-mode .v2-col-span-2, body.kiosk-v2-active .v2-col-span-2 { grid-column: span 3; }
/* v2-col-span-1: span 1 유지 (25%→17%, 밀도 증가) */

/* Kiosk widget cards: 글자·패딩 축소 */
body.kiosk-mode .v2-widget-card,
body.kiosk-v2-active .v2-widget-card {
    font-size: 0.8em;
    border-radius: 0.5rem;
}
body.kiosk-mode .v2-widget-card .p-4,
body.kiosk-v2-active .v2-widget-card .p-4 {
    padding: 0.5rem !important;
}
body.kiosk-mode .v2-widget-card .p-3,
body.kiosk-v2-active .v2-widget-card .p-3 {
    padding: 0.375rem !important;
}

/* Hide main header in V1 kiosk (URL ?kiosk) — widgets are self-contained */
body.kiosk-mode.v2-widget-active #main-view-container > .flex-shrink-0:first-child {
    display: none !important;
}
/* V2 kiosk (button): header 축소는 dashboard.css에서 선별 처리 */

/* ─── V2 Normal Mode (non-kiosk) ─────────────────────────── */

/* Normal mode: 그리드가 콘텐츠 높이에 맞게 자연 성장, 스크롤은 부모(#main-view-container)가 담당 */
body:not(.kiosk-mode).v2-widget-active #main-view-container {
    overflow-y: auto;
    min-height: 0;
}
body:not(.kiosk-mode).v2-widget-active .v2-widget-grid--active {
    grid-template-rows: none;
    grid-auto-rows: auto;
    padding: 1rem;
    padding-bottom: 80px; /* FAB 버튼(64px) + 여유(16px) — 하단 위젯 겹침 방지 */
    /* flex-col 부모 안에서 그리드가 압축되지 않도록 보장.
       overflow:hidden + flex-shrink:1 → min-height:0 해소 → 섹션 겹침 방지 */
    flex-shrink: 0;
}

/* ─── V2 Widget Controls (hover overlay) ─────────────────── */

.v2-widget-card {
    position: relative;
}

.v2-widget-controls {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
    pointer-events: none;
}

.v2-widget-card:hover .v2-widget-controls {
    opacity: 1;
    pointer-events: auto;
}

/* Touch devices: always show controls (no hover available) */
@media (hover: none) {
    .v2-widget-controls {
        opacity: 1;
        pointer-events: auto;
    }
    .v2-widget-controls button {
        width: 44px;
        height: 44px;
    }
}

.v2-widget-controls button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(255, 255, 255, 0.9);
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    line-height: 1;
    backdrop-filter: blur(4px);
}

.dark .v2-widget-controls button {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(71, 85, 105, 0.5);
    color: #94a3b8;
}

.v2-widget-controls button:hover {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.4);
    color: #3b82f6;
}

.dark .v2-widget-controls button:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
    color: #60a5fa;
}

.v2-widget-controls button[data-action="hide"]:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

.v2-widget-controls button[data-action="help"] {
    color: #6366f1;
    border-color: rgba(99, 102, 241, 0.3);
}
.dark .v2-widget-controls button[data-action="help"] {
    color: #a5b4fc;
    border-color: rgba(129, 140, 248, 0.3);
}
.v2-widget-controls button[data-action="help"]:hover {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.5);
    color: #4f46e5;
}
.dark .v2-widget-controls button[data-action="help"]:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(129, 140, 248, 0.5);
    color: #c7d2fe;
}

/* ─── V2 Help Popover ─────────────────────────────────────── */
.v2-help-popover {
    position: fixed;
    z-index: 9999;
    width: 320px;
    max-width: calc(100vw - 16px);
    max-height: min(400px, 60vh);
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 12px;
    box-shadow: 0 8px 30px -8px rgba(15, 23, 42, 0.2);
    backdrop-filter: blur(8px);
    font-size: 13px;
    line-height: 1.55;
    color: #334155;
    animation: v2HelpFadeIn 0.15s ease-out;
}
.dark .v2-help-popover {
    background: rgba(15, 23, 42, 0.98);
    border-color: rgba(71, 85, 105, 0.6);
    color: #cbd5e1;
    box-shadow: 0 8px 30px -8px rgba(0, 0, 0, 0.4);
}
@keyframes v2HelpFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.v2-help-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}
.dark .v2-help-popover-header {
    border-bottom-color: rgba(71, 85, 105, 0.4);
}
.v2-help-popover-title {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
}
.dark .v2-help-popover-title {
    color: #f1f5f9;
}
.v2-help-popover-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 6px;
    font-size: 16px;
    line-height: 1;
    transition: all 0.12s ease;
}
.v2-help-popover-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}
.v2-help-popover-body {
    padding: 10px 14px 14px;
}
.v2-help-popover-body p {
    margin: 0;
}
.v2-help-popover-body table {
    margin-top: 4px;
}
.v2-help-popover-body table td {
    padding: 3px 6px;
    vertical-align: top;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}
.dark .v2-help-popover-body table td {
    border-bottom-color: rgba(71, 85, 105, 0.3);
}

.v2-widget-controls button.v2-drag-handle {
    cursor: grab;
}
.v2-widget-controls button.v2-drag-handle:active {
    cursor: grabbing;
}

/* ─── 좌상단 드래그 핸들 (T12) ─────────────────────── */
.v2-drag-handle-corner {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 22px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    cursor: grab;
    padding: 0;
    opacity: 0.35;
    transition: opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    z-index: 11;
}
.v2-drag-handle-corner:hover {
    opacity: 1;
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.35);
    color: #4f46e5;
}
.dark .v2-drag-handle-corner {
    color: #64748b;
}
.dark .v2-drag-handle-corner:hover {
    background: rgba(99, 102, 241, 0.22);
    border-color: rgba(129, 140, 248, 0.45);
    color: #c7d2fe;
}
.v2-drag-handle-corner:active {
    cursor: grabbing;
}
/* 카드 호버 시 핸들 선명도 증가 */
.v2-widget-card:hover .v2-drag-handle-corner {
    opacity: 0.9;
}
/* 터치 기기 — 핸들 항상 선명하게 + 크기 키움 */
@media (hover: none) {
    .v2-drag-handle-corner {
        opacity: 0.85;
        width: 32px;
        height: 36px;
    }
}
/* 키오스크 모드에서는 드래그 핸들 숨김 */
body.kiosk-mode .v2-drag-handle-corner {
    display: none;
}

/* ─── Resize 미니 셀렉터 팝오버 (T11) ──────────────── */
.v2-resize-group {
    position: relative;
    display: inline-flex;
}
.v2-resize-popover {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    display: none;
    gap: 2px;
    padding: 4px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 6px 20px -6px rgba(15, 23, 42, 0.2);
    backdrop-filter: blur(4px);
    z-index: 20;
}
.dark .v2-resize-popover {
    background: rgba(15, 23, 42, 0.97);
    border-color: rgba(71, 85, 105, 0.6);
}
/* hover 또는 키보드 focus 중일 때 팝오버 표시 */
.v2-resize-group:hover .v2-resize-popover,
.v2-resize-group:focus-within .v2-resize-popover {
    display: flex;
}
/* 팝오버 버튼 — 기본 controls 스타일 오버라이드 (더 작게) */
.v2-resize-popover button {
    width: 24px !important;
    height: 24px !important;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: transparent;
    color: #64748b;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: all 0.12s ease;
}
.dark .v2-resize-popover button {
    color: #94a3b8;
    border-color: rgba(71, 85, 105, 0.5);
}
.v2-resize-popover button:hover {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.45);
    color: #3b82f6;
}
.v2-resize-popover button.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.55);
    color: #4f46e5;
}
.dark .v2-resize-popover button.active {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(129, 140, 248, 0.55);
    color: #c7d2fe;
}
/* 세로 크기 팝오버 — 세로 방향으로 표시 */
.v2-resize-popover-v {
    flex-direction: column;
}
/* 터치 기기에서는 팝오버가 크기 셀렉터 자체 역할도 하므로 상시 표시 + 버튼 크게 */
@media (hover: none) {
    .v2-resize-popover button {
        width: 36px !important;
        height: 36px !important;
        font-size: 13px;
    }
}
/* 위젯 카드 키보드 포커스 — 크기 단축키(1~4) 사용 힌트 */
.v2-widget-card:focus-visible {
    outline: 2px solid rgba(99, 102, 241, 0.55);
    outline-offset: 2px;
}

/* ─── V2 Widget Expand Overlay (modal) ───────────────────── */

#v2-widget-expand-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

#v2-widget-expand-overlay.active {
    display: flex;
}

#v2-widget-expand-content {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    width: calc(100vw - 2rem);
    height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    position: relative;
}

.dark #v2-widget-expand-content {
    background: #1e293b;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

#v2-widget-expand-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.dark #v2-widget-expand-header {
    border-color: #334155;
}

#v2-widget-expand-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: none;
    background: rgba(148, 163, 184, 0.1);
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
}

#v2-widget-expand-close:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

#v2-widget-expand-body {
    padding: 1.25rem;
    flex: 1;
    overflow-y: auto !important;   /* 위젯 JS의 inline overflow:hidden 방어 */
    min-height: 0;
    max-height: none !important;   /* 위젯 JS의 inline maxHeight 방어 */
}
/* 위젯 JS가 expand body에 v2-widget-card 클래스를 추가해도 max-height 제한 무시 */
#v2-widget-expand-body.v2-widget-card {
    max-height: none !important;
    overflow-y: auto !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: transparent !important;
}

/* ─── V2 Widget Drag feedback ────────────────────────────── */

.v2-widget-card.v2-dragging {
    opacity: 0.5;
    border: 2px dashed #3b82f6;
    transform: scale(0.97);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.v2-widget-card.v2-drag-over-before::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #3b82f6;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

.v2-widget-card.v2-drag-over-after::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #3b82f6;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

/* ─── V2 Widget Utilities ─────────────────────────────────── */

/* V2 custom scrollbar */
.v2-custom-scrollbar::-webkit-scrollbar { width: 4px; }
.v2-custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.v2-custom-scrollbar::-webkit-scrollbar-thumb { background: #475569; border-radius: 2px; }

/* V2 chart tab button active state */
.v2-chart-tab-btn.active {
    background-color: #3b82f6 !important;
    color: white !important;
}

/* V2 filter button active state */
.v2-widget-card .filter-btn.active {
    background-color: #3b82f6 !important;
    color: white !important;
}

/* V2 filter bar status buttons — base active */
.v2-status-filter.active {
    background-color: #3b82f6 !important;
    color: white !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* 상태별 활성 색상 (시각 일관성 — 위젯 상태 색상과 매칭) */
.v2-status-filter.active[data-status="up"] {
    background-color: #10b981 !important; /* emerald-500 */
}
.v2-status-filter.active[data-status="warning"] {
    background-color: #f59e0b !important; /* amber-500 */
}
.v2-status-filter.active[data-status="down"] {
    background-color: #ef4444 !important; /* red-500 */
}
.v2-status-filter.active[data-status="all"] {
    background-color: #3b82f6 !important; /* blue-500 */
}

/* 필터바 발견성 — 좌측 액센트 + 약한 그림자 */
#v2-filter-bar:not(.hidden) {
    border-left: 3px solid #3b82f6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.dark #v2-filter-bar:not(.hidden) {
    border-left-color: #60a5fa;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* 활성 필터 카운트 배지 — 살짝 펄스 (사용자 주의 환기) */
#v2-filter-active-count:not(.hidden) {
    animation: v2-badge-pop 0.25s ease-out;
}
@keyframes v2-badge-pop {
    0%   { transform: scale(0.7); opacity: 0; }
    60%  { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

/* Hide filter bar in kiosk mode */
body.kiosk-mode #v2-filter-bar,
body.kiosk-v2-active #v2-filter-bar {
    display: none !important;
}

/* ─── V2 Section (group) styles ──────────────────────────── */
.v2-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.v2-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0;
    cursor: pointer;
    user-select: none;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}

.v2-section-header:hover {
    opacity: 0.8;
}

.v2-section-content {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.v2-section-chevron {
    transition: transform 0.2s ease;
}
.v2-section-chevron.rotate-180 {
    transform: rotate(180deg);
}

/* ─── V2 Section Drag & Drop ─────────────────────────────── */
.v2-section-drag-handle {
    opacity: 0;
    transition: opacity 0.2s;
    cursor: grab;
    color: #64748b;
    font-size: 14px;
    user-select: none;
    line-height: 1;
}
.v2-section-header:hover .v2-section-drag-handle {
    opacity: 1;
}
.v2-section-drag-handle:active {
    cursor: grabbing;
}
.dark .v2-section-drag-handle {
    color: #94a3b8;
}

.v2-section.v2-section-dragging {
    opacity: 0.5;
    border: 2px dashed #8b5cf6;
    border-radius: 0.75rem;
}

.v2-section.v2-section-drop-before::before {
    content: '';
    display: block;
    height: 3px;
    background: #8b5cf6;
    border-radius: 2px;
    margin-bottom: 0.5rem;
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.5);
}
.v2-section.v2-section-drop-after::after {
    content: '';
    display: block;
    height: 3px;
    background: #8b5cf6;
    border-radius: 2px;
    margin-top: 0.5rem;
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.5);
}

/* ─── V2 Split View 활성 시: 기존 위젯 그리드·뷰 컨테이너 숨김 ─── */
body.v2-split-active #main-view-container .v2-widget-grid,
body.v2-split-active #main-view-container .view-container,
body.v2-split-active #v2-filter-bar {
    display: none !important;
}

/* ─── V2 Split View (3D + Dashboard side-by-side) ─────────── */

#v2-split-view {
    display: none;
}

#v2-split-view.active {
    display: flex;
    flex: 1;
    min-height: 0;
}

.v2-split-panel {
    flex: 1;
    min-width: 300px;
}

#v2-split-left {
    overflow-y: auto;
}

/* Split 좌측 패널 내 위젯 그리드 */
#v2-split-left .v2-widget-grid--active {
    grid-auto-rows: auto;
    overflow-y: auto;
    padding: 0.75rem;
}

#v2-split-right {
    overflow: hidden;
}

/* Split 우측 3D 뷰어가 전체 공간 차지 */
#v2-split-right canvas {
    width: 100% !important;
    height: 100% !important;
}

#v2-split-divider {
    flex-shrink: 0;
}

#v2-split-divider:active {
    background-color: #3b82f6 !important;
}

/* ─── V2 Edge Resize Handles ─────────────────────────────── */

/* 리사이즈 핸들 — 위젯 호버 시 나타남 */
.v2-resize-edge { position: absolute; opacity: 0; transition: opacity 0.15s; z-index: 5; }
.v2-widget-card:hover > .v2-resize-edge { opacity: 1; }

.v2-resize-edge--right  { right: 0; top: 8px; bottom: 8px; width: 6px; cursor: col-resize; border-radius: 3px; }
.v2-resize-edge--bottom { left: 8px; bottom: 0; right: 8px; height: 6px; cursor: row-resize; border-radius: 3px; }
.v2-resize-edge--corner { right: 0; bottom: 0; width: 14px; height: 14px; cursor: nwse-resize; }

/* 호버 시 파란 하이라이트 */
.v2-resize-edge--right:hover  { background: rgba(59,130,246,0.25); }
.v2-resize-edge--bottom:hover { background: rgba(59,130,246,0.25); }
.v2-resize-edge--corner:hover { background: rgba(59,130,246,0.15); }
.v2-resize-edge--corner:hover::after {
    content: ''; position: absolute; right: 3px; bottom: 3px;
    width: 8px; height: 8px;
    border-right: 2px solid rgba(59,130,246,0.6);
    border-bottom: 2px solid rgba(59,130,246,0.6);
}

/* 드래그 중 고스트 오버레이 */
.v2-resize-ghost {
    position: fixed; border: 2px dashed #3b82f6; border-radius: 0.75rem;
    background: rgba(59,130,246,0.08); pointer-events: none; z-index: 9998;
    transition: none;
}
.v2-resize-ghost-label {
    position: absolute; bottom: -24px; right: 0;
    background: #1e293b; color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 4px;
    white-space: nowrap;
}

/* 키오스크 모드에서는 리사이즈 핸들 숨김 */
body.kiosk-mode .v2-resize-edge,
body.kiosk-v2-active .v2-resize-edge {
    display: none;
}

/* ─── V2 Responsive ───────────────────────────────────────── */

/* Wide desktop (>= 1536px): 4 cols with generous gap */
@media (min-width: 1536px) {
    .v2-widget-grid--active {
        gap: 1rem;
        padding: 1rem;
    }
}

/* Tablet landscape (< 1280px): keep 4 cols but tighter gap */
@media (max-width: 1280px) {
    .v2-widget-grid--active {
        gap: 0.5rem;
        padding: 0.5rem;
    }
}

/* Small laptop (< 1024px): 3 columns, span-4→3 */
@media (max-width: 1024px) {
    .v2-widget-grid--active {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    .v2-col-span-4 {
        grid-column: span 3;
    }
    .v2-col-span-3 {
        grid-column: span 3;
    }
    /* 2026-06-08: 소형 키오스크 안전장치 — 6열→4열 복원 */
    body.kiosk-mode .v2-widget-grid--active,
    body.kiosk-v2-active .v2-widget-grid--active {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    body.kiosk-mode .v2-col-span-4, body.kiosk-v2-active .v2-col-span-4 { grid-column: span 4; }
    body.kiosk-mode .v2-col-span-3, body.kiosk-v2-active .v2-col-span-3 { grid-column: span 3; }
    body.kiosk-mode .v2-col-span-2, body.kiosk-v2-active .v2-col-span-2 { grid-column: span 2; }
    /* Tab bar: scroll horizontally */
    #v2-tab-bar {
        -webkit-overflow-scrolling: touch;
    }
    /* Filter bar: wrap */
    #v2-filter-bar {
        gap: 0.5rem;
    }
}

/* Tablet portrait (< 768px): collapse to 2 columns */
@media (max-width: 768px) {
    .v2-widget-grid--active {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .v2-col-span-3,
    .v2-col-span-4 {
        grid-column: span 2;
    }
    /* Tab bar: compact */
    .v2-tab {
        padding: 3px 8px;
        font-size: 11px;
    }
    .v2-tab-actions {
        display: none !important;
    }
}

/* Mobile (< 640px): single column, reset row spans */
@media (max-width: 640px) {
    .v2-widget-grid--active {
        grid-template-columns: 1fr !important;
        grid-auto-rows: auto !important;
        overflow-y: auto !important;
    }
    .v2-col-span-1,
    .v2-col-span-2,
    .v2-col-span-3,
    .v2-col-span-4 {
        grid-column: span 1;
    }
    .v2-row-span-2,
    .v2-row-span-3,
    .v2-row-span-4,
    .v2-row-span-5,
    .v2-row-span-6 {
        grid-row: span 1;
        min-height: 0;
        align-self: auto;
    }
    .v2-widget-card {
        overflow-y: auto;
    }
    /* Filter bar: stack */
    #v2-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ─── V2 Threshold Alert Borders ─────────────────────────── */
.v2-threshold-warning {
    border-color: #f59e0b !important;
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.3);
}
.v2-threshold-critical {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.3);
    animation: v2ThresholdPulse 2s ease-in-out infinite;
}
@keyframes v2ThresholdPulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2); }
}

/* ─── Server Status Visual Emphasis ──────────────────────── */
.v2-card-critical {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.3), 0 0 12px rgba(239, 68, 68, 0.15);
    animation: v2CardCriticalPulse 2s ease-in-out infinite;
}
@keyframes v2CardCriticalPulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.3), 0 0 12px rgba(239, 68, 68, 0.15); }
    50% { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.4), 0 0 20px rgba(239, 68, 68, 0.25); }
}
.v2-card-warning {
    border-color: #f59e0b !important;
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.3);
}
.v2-card-down {
    border-color: #ef4444 !important;
    opacity: 0.85;
    background: repeating-linear-gradient(
        -45deg,
        transparent, transparent 8px,
        rgba(239, 68, 68, 0.03) 8px, rgba(239, 68, 68, 0.03) 16px
    );
}
.v2-card-spike {
    position: relative;
}
.v2-card-spike::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    animation: v2SpikeBlink 1s ease-in-out infinite;
}
@keyframes v2SpikeBlink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.7); }
}
.v2-card-active {
    border-left: 3px solid #22c55e !important;
}
/* [주석처리] idle 회색 보더 — 유휴 구분이 직관적이지 않아 비활성화 (2026-04-30)
.v2-card-idle {
    border-left: 3px solid #9ca3af !important;
}
*/
/* Status dot indicator */
.v2-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}
.v2-status-dot-active {
    background: #22c55e;
    box-shadow: 0 0 4px rgba(34, 197, 94, 0.4);
}
/* [주석처리] idle 회색 dot — 초록 dot으로 통일 (2026-04-30)
.v2-status-dot-idle {
    background: #9ca3af;
}
*/
.v2-status-dot-down {
    background: #ef4444;
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.4);
}
/* Spike badge in server list */
.v2-spike-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 6px;
    font-size: 9px;
    font-weight: 700;
    border-radius: 9999px;
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
    animation: v2SpikeBlink 1s ease-in-out infinite;
}
.dark .v2-spike-badge {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

/* ─── Widget Container Size Hints ────────────────────────── */
/* Set by widgetResponsive.js via ResizeObserver */
.v2-widget-card[data-width="xs"] { /* < 200px */ }
.v2-widget-card[data-width="sm"] { /* 200-400px */ }
.v2-widget-card[data-width="md"] { /* 400-600px */ }
.v2-widget-card[data-width="lg"] { /* > 600px */ }

/* ─── Widget Auto-Recovery Spinner (W4-C) ────────────────── */
.v2-recovery-spin {
    display: inline-block;
    animation: v2RecoverySpin 1.2s linear infinite;
}
@keyframes v2RecoverySpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ─── Reduced Motion (W4-B) ──────────────────────────────── */
/* 모션 민감 사용자/저전력 모드 — transition·animation 최소화.
   키오스크 24/7 환경에서도 동일하게 적용되어 시각적 부담을 줄인다. */
@media (prefers-reduced-motion: reduce) {
    .v2-widget-card,
    .v2-widget-card *,
    .v2-toast,
    [class*="v2-toast"],
    #v2-widget-expand-overlay,
    #v2-widget-expand-overlay *,
    #v2-confirm-modal,
    #v2-confirm-modal *,
    #v2-keyboard-help-modal,
    #v2-keyboard-help-modal *,
    .v2-tour-overlay,
    .v2-tour-tooltip,
    .v2-spike-badge {
        transition-duration: 0.01ms !important;
        transition-delay: 0ms !important;
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}

/* ─── Onboarding Tour (V2 Usability #1) ───────────────────────────────── */

.v2-tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    pointer-events: auto;
    /* CSS 변수로 spotlight 위치 제어 (JS에서 주입) */
    --spot-x: 50%;
    --spot-y: 50%;
    --spot-w: 0px;
    --spot-h: 0px;
    /* spotlight 컷아웃은 ::before의 거대 box-shadow로 처리 */
    background: transparent;
}

.v2-tour-overlay::before {
    content: "";
    position: fixed;
    left: var(--spot-x);
    top: var(--spot-y);
    width: var(--spot-w);
    height: var(--spot-h);
    border-radius: 12px;
    /* 거대한 box-shadow로 spotlight 외 영역을 어둡게 */
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.72);
    background: transparent;
    outline: 3px solid rgba(99, 102, 241, 0.9);
    outline-offset: 2px;
    transition: left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease;
    pointer-events: none;
}

.v2-tour-tooltip {
    position: fixed;
    z-index: 9001;
    width: 360px;
    max-width: calc(100vw - 32px);
    background: #ffffff;
    color: #0f172a;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    padding: 20px 22px 18px;
    font-family: inherit;
    transition: left 0.25s ease, top 0.25s ease;
}

:is(.dark) .v2-tour-tooltip {
    background: #1e293b;
    color: #f1f5f9;
}

.v2-tour-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.v2-tour-step-indicator {
    font-size: 12px;
    font-weight: 600;
    color: #6366f1;
    letter-spacing: 0.05em;
}

.v2-tour-skip {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.v2-tour-skip:hover {
    background: rgba(100, 116, 139, 0.12);
    color: #0f172a;
}

:is(.dark) .v2-tour-skip:hover {
    color: #f1f5f9;
}

.v2-tour-title {
    margin: 0 0 8px 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.4;
}

.v2-tour-body {
    margin: 0 0 16px 0;
    font-size: 13.5px;
    line-height: 1.55;
    color: #475569;
}

:is(.dark) .v2-tour-body {
    color: #cbd5e1;
}

.v2-tour-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.v2-tour-prev,
.v2-tour-next {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s ease, transform 0.1s ease;
}

.v2-tour-prev {
    background: transparent;
    border-color: #cbd5e1;
    color: #475569;
}

.v2-tour-prev:hover:not(:disabled) {
    background: #f1f5f9;
}

.v2-tour-prev:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

:is(.dark) .v2-tour-prev {
    border-color: #475569;
    color: #cbd5e1;
}

:is(.dark) .v2-tour-prev:hover:not(:disabled) {
    background: #334155;
}

.v2-tour-next {
    background: #6366f1;
    color: #ffffff;
}

.v2-tour-next:hover {
    background: #4f46e5;
    transform: translateY(-1px);
}

.v2-tour-next:active {
    transform: translateY(0);
}

/* ─── V2 Widget Disabled (Exporter 미설치) ────────────── */
.v2-widget-disabled {
    opacity: 0.4;
    pointer-events: none;
    position: relative;
}
.v2-widget-disabled .v2-widget-controls {
    pointer-events: auto;
    opacity: 1;
}
