/* ===== Theme Variables ===== */
:root,
[data-theme="indigo"] {
    --sidebar-width: 220px;
    --sidebar-collapsed-width: 52px;
    --sidebar-bg: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(99, 102, 241, 0.2);
    --sidebar-active-border: #6366f1;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-text: rgba(255, 255, 255, 0.55);
    --sidebar-text-hover: rgba(255, 255, 255, 0.9);
    --sidebar-section-text: rgba(255, 255, 255, 0.35);
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-soft: rgba(99, 102, 241, 0.1);
    --accent-soft-hover: rgba(99, 102, 241, 0.18);
    --accent-soft-border: rgba(99, 102, 241, 0.25);
    --accent-soft-focus: rgba(99, 102, 241, 0.35);
    --accent-rgb: 99, 102, 241;
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-header: #ffffff;
    --bg-table-header: #f8fafc;
    --bg-table-hover: #f8fafc;
    --bg-input: #ffffff;
    --topbar-height: 44px;
    --topbar-bg: #ffffff;
    --topbar-border: #e2e8f0;
    --topbar-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-heading: #0f172a;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
    --toolbar-gradient-overlay: rgba(255, 255, 255, 0.45);
    --logo-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --login-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

[data-theme="ocean"] {
    --sidebar-bg: linear-gradient(180deg, #164e63 0%, #0c4a6e 100%);
    --sidebar-active: rgba(8, 145, 178, 0.25);
    --sidebar-active-border: #06b6d4;
    --accent: #0e7490;
    --accent-light: #22d3ee;
    --accent-soft: rgba(8, 145, 178, 0.1);
    --accent-soft-hover: rgba(8, 145, 178, 0.18);
    --accent-soft-border: rgba(8, 145, 178, 0.25);
    --accent-soft-focus: rgba(8, 145, 178, 0.35);
    --accent-rgb: 8, 145, 178;
    --bg-body: #f0f9ff;
    --bg-card: #f8fdff;
    --bg-card-header: #f0f9fc;
    --bg-table-header: #e8f6fa;
    --bg-table-hover: #edf8fb;
    --bg-input: #f8fdff;
    --topbar-bg: #f0f9fc;
    --topbar-border: #c8e6ef;
    --border-color: #c8e6ef;
    --border-light: #e0f2f7;
    --toolbar-gradient-overlay: rgba(224, 242, 247, 0.5);
    --logo-gradient: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
    --login-gradient: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
}

[data-theme="ocean-depths"] {
    --sidebar-bg: linear-gradient(180deg, #1a2332 0%, #0f1822 100%);
    --sidebar-active: rgba(42, 133, 133, 0.28);
    --sidebar-active-border: #4fb8b8;
    --accent: #2a8585;
    --accent-light: #7ccaca;
    --accent-soft: rgba(42, 133, 133, 0.1);
    --accent-soft-hover: rgba(42, 133, 133, 0.18);
    --accent-soft-border: rgba(42, 133, 133, 0.25);
    --accent-soft-focus: rgba(42, 133, 133, 0.35);
    --accent-rgb: 42, 133, 133;
    --bg-body: #f0f8f4;
    --bg-card: #fbfefc;
    --bg-card-header: #eff7f3;
    --bg-table-header: #e3f1ec;
    --bg-table-hover: #eaf5f0;
    --bg-input: #fbfefc;
    --topbar-bg: #eff7f3;
    --topbar-border: #c5e0da;
    --border-color: #c5e0da;
    --border-light: #dceee8;
    --toolbar-gradient-overlay: rgba(224, 240, 235, 0.5);
    --logo-gradient: linear-gradient(135deg, #2a8585 0%, #a8dadc 100%);
    --login-gradient: linear-gradient(135deg, #1a2332 0%, #2a8585 100%);
}

[data-theme="forest"] {
    --sidebar-bg: linear-gradient(180deg, #14532d 0%, #064e3b 100%);
    --sidebar-active: rgba(5, 150, 105, 0.25);
    --sidebar-active-border: #10b981;
    --accent: #047857;
    --accent-light: #34d399;
    --accent-soft: rgba(5, 150, 105, 0.1);
    --accent-soft-hover: rgba(5, 150, 105, 0.18);
    --accent-soft-border: rgba(5, 150, 105, 0.25);
    --accent-soft-focus: rgba(5, 150, 105, 0.35);
    --accent-rgb: 5, 150, 105;
    --bg-body: #f0fdf4;
    --bg-card: #f7fdf9;
    --bg-card-header: #effaf2;
    --bg-table-header: #e5f6ea;
    --bg-table-hover: #ebf8ef;
    --bg-input: #f7fdf9;
    --topbar-bg: #effaf2;
    --topbar-border: #bfe5c8;
    --border-color: #bfe5c8;
    --border-light: #dcf0e1;
    --toolbar-gradient-overlay: rgba(220, 240, 225, 0.5);
    --logo-gradient: linear-gradient(135deg, #059669 0%, #10b981 100%);
    --login-gradient: linear-gradient(135deg, #059669 0%, #047857 100%);
}

[data-theme="rose"] {
    --sidebar-bg: linear-gradient(180deg, #4c0519 0%, #3b0764 100%);
    --sidebar-active: rgba(225, 29, 72, 0.25);
    --sidebar-active-border: #f43f5e;
    --accent: #be123c;
    --accent-light: #fb7185;
    --accent-soft: rgba(225, 29, 72, 0.1);
    --accent-soft-hover: rgba(225, 29, 72, 0.18);
    --accent-soft-border: rgba(225, 29, 72, 0.25);
    --accent-soft-focus: rgba(225, 29, 72, 0.35);
    --accent-rgb: 225, 29, 72;
    --bg-body: #fff1f2;
    --bg-card: #fffbfc;
    --bg-card-header: #fdf2f4;
    --bg-table-header: #fbe8ec;
    --bg-table-hover: #fcecef;
    --bg-input: #fffbfc;
    --topbar-bg: #fdf2f4;
    --topbar-border: #f0c4cc;
    --border-color: #f0c4cc;
    --border-light: #f7dde2;
    --toolbar-gradient-overlay: rgba(247, 221, 226, 0.5);
    --logo-gradient: linear-gradient(135deg, #e11d48 0%, #f43f5e 100%);
    --login-gradient: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
}

[data-theme="desert-rose"] {
    --sidebar-bg: linear-gradient(180deg, #5d2e46 0%, #3d1e30 100%);
    --sidebar-active: rgba(168, 88, 78, 0.25);
    --sidebar-active-border: #d4a5a5;
    --accent: #a8584e;
    --accent-light: #d4a5a5;
    --accent-soft: rgba(168, 88, 78, 0.1);
    --accent-soft-hover: rgba(168, 88, 78, 0.18);
    --accent-soft-border: rgba(168, 88, 78, 0.25);
    --accent-soft-focus: rgba(168, 88, 78, 0.35);
    --accent-rgb: 168, 88, 78;
    --bg-body: #fbf4ee;
    --bg-card: #fffcfa;
    --bg-card-header: #faf1ea;
    --bg-table-header: #f3e5da;
    --bg-table-hover: #f7ece3;
    --bg-input: #fffcfa;
    --topbar-bg: #faf1ea;
    --topbar-border: #e6cdbe;
    --border-color: #e6cdbe;
    --border-light: #f1e2d7;
    --toolbar-gradient-overlay: rgba(241, 226, 215, 0.5);
    --logo-gradient: linear-gradient(135deg, #a8584e 0%, #d4a5a5 100%);
    --login-gradient: linear-gradient(135deg, #8c4a55 0%, #5d2e46 100%);
}

[data-theme="dark"] {
    --sidebar-bg: linear-gradient(180deg, #18181b 0%, #09090b 100%);
    --sidebar-border: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(139, 92, 246, 0.2);
    --sidebar-active-border: #8b5cf6;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --accent-soft: rgba(139, 92, 246, 0.15);
    --accent-soft-hover: rgba(139, 92, 246, 0.22);
    --accent-soft-border: rgba(139, 92, 246, 0.30);
    --accent-soft-focus: rgba(139, 92, 246, 0.40);
    --accent-rgb: 139, 92, 246;
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-card-header: #1e293b;
    --bg-table-header: #1e293b;
    --bg-table-hover: rgba(255, 255, 255, 0.03);
    --bg-input: #1e293b;
    --topbar-bg: #1e293b;
    --topbar-border: #334155;
    --topbar-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --text-primary: #e2e8f0;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --text-heading: #f1f5f9;
    --border-color: #334155;
    --border-light: #1e293b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
    --toolbar-gradient-overlay: rgba(255, 255, 255, 0.03);
    --logo-gradient: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
    --login-gradient: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
}

/* ===== Global ===== */
body {
    background-color: var(--bg-body);
    font-family: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

html, body {
    height: 100%;
}

body:not(.no-sidebar) {
    overflow: hidden;
}

body:not(.no-sidebar) > .d-flex {
    height: 100vh;
    overflow: hidden;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover {
    color: var(--accent-light);
}

::selection {
    background: var(--accent-soft);
    color: var(--text-primary);
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    background: var(--sidebar-bg);
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.12);
}

.sidebar > .nav {
    display: block; /* Bootstrap .nav의 flex를 차단 — 스크롤 컨테이너는 block이어야 함 */
    width: 100%;
    overflow-y: scroll;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.50) rgba(255, 255, 255, 0.08);
}

.sidebar > .nav > .nav-item,
.sidebar > .nav > .nav-section-label,
.sidebar > .nav > .nav-section-items {
    width: 100%;
}

.sidebar-header {
    padding: 14px 14px 12px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-header h5 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #fff;
}

.sidebar-header .logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--logo-gradient);
    margin-right: 8px;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-header small {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.63rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Sidebar Footer */
.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 14px;
    border-top: 1px solid var(--sidebar-border);
    text-align: center;
    background: var(--sidebar-bg);
}
.sidebar-footer small {
    color: rgba(255, 255, 255, 0.25);
    font-size: 0.6rem;
    letter-spacing: 0.3px;
}
/* 푸터 링크는 어두운 사이드바 위에서 항상 보이도록 사이드바 텍스트 색 사용
   (Bootstrap .text-muted 가 밝은 모드에서 어두운 회색이라 묻히는 문제 해결) */
.sidebar-footer small a,
.sidebar-footer small a.text-muted {
    color: var(--sidebar-text) !important;
    transition: color 0.15s ease;
}
.sidebar-footer small a:hover,
.sidebar-footer small a.text-muted:hover {
    color: var(--sidebar-text-hover) !important;
}
.sidebar.collapsed .sidebar-footer { display: none; }

/* Sidebar Menu Search */
.sidebar-search {
    padding: 8px 12px 4px;
}
.sidebar-search-box {
    position: relative;
    display: flex;
    align-items: center;
}
.sidebar-search-icon {
    position: absolute;
    left: 8px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
    pointer-events: none;
}
.sidebar-search-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.78rem;
    padding: 5px 28px 5px 28px;
    outline: none;
    transition: background 0.2s, border-color 0.2s;
}
.sidebar-search-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}
.sidebar-search-input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}
.sidebar-search-input::-webkit-search-cancel-button {
    display: none;
}
.sidebar-search-clear {
    position: absolute;
    right: 4px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.65rem;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
}
.sidebar-search-clear:hover {
    color: rgba(255, 255, 255, 0.7);
}
.sidebar-search-empty {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.72rem;
    text-align: center;
    padding: 12px 8px 4px;
}
.sidebar .nav-item.menu-search-hidden {
    display: none !important;
}
.sidebar .nav-section-label.menu-search-hidden {
    display: none !important;
}
.sidebar .nav-section-items.menu-search-hidden {
    display: none !important;
}
.sidebar .nav-item .nav-link .menu-search-highlight {
    background: rgba(255, 215, 0, 0.35);
    color: #fff;
    border-radius: 2px;
    padding: 0 1px;
}
.sidebar.collapsed .sidebar-search {
    display: none;
}

/* Section Labels */
.sidebar .nav-section-label {
    color: var(--sidebar-section-text);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 14px 14px 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: color 0.2s;
}
.sidebar .nav-section-label .section-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.sidebar .nav-section-label .section-text > span {
    white-space: nowrap;
}
.sidebar .nav-section-label .section-icon {
    font-size: 0.82rem;
    opacity: 0.9;
    flex: 0 0 auto;
}
.sidebar .nav-section-label:hover {
    color: rgba(255, 255, 255, 0.55);
}
.sidebar .nav-section-label .section-chevron {
    font-size: 0.6rem;
    transition: transform 0.25s ease;
}
.sidebar .nav-section-label.collapsed .section-chevron {
    transform: rotate(-90deg);
}

/* Collapsible section items */
.sidebar .nav-section-items {
    overflow: hidden;
    max-height: 2000px;
    transition: max-height 0.3s ease, opacity 0.25s ease;
    opacity: 1;
}
.sidebar .nav-section-items.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Sub-group label */
.sidebar .nav-sub-label {
    color: var(--sidebar-section-text);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 6px 14px 2px 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: color 0.2s;
    margin-top: 2px;
}
.sidebar .nav-sub-label:hover {
    color: rgba(255, 255, 255, 0.6);
}
.sidebar .nav-sub-label .sub-chevron {
    font-size: 0.6rem;
    transition: transform 0.2s ease;
}
.sidebar .nav-sub-label.expanded .sub-chevron {
    transform: rotate(90deg);
}

/* Sub-group items */
.sidebar .nav-sub-items {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}
.sidebar .nav-sub-items.expanded {
    max-height: 300px;
    opacity: 1;
}
.sidebar .nav-sub-items .nav-link {
    padding-left: 28px;
    font-size: 0.75rem;
}

/* Nav Links */
.sidebar .nav-link {
    padding: 6px 10px;
    border-radius: 6px;
    margin: 1px 8px;
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--sidebar-text);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    position: relative;
}

.sidebar .nav-link i {
    font-size: 0.85rem;
    width: 18px;
    text-align: center;
    margin-right: 8px;
    opacity: 0.55;
    transition: opacity 0.15s, color 0.15s;
}

.sidebar .nav-link:hover {
    background-color: var(--sidebar-hover);
    color: var(--sidebar-text-hover);
}
.sidebar .nav-link:hover i {
    opacity: 0.9;
}

.sidebar .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 500;
    border-left: 2px solid var(--sidebar-active-border);
    padding-left: 8px;
}
.sidebar .nav-link.active i {
    opacity: 1;
    color: var(--accent-light);
}

/* ===== 메뉴 즐겨찾기 별표 ===== */
.sidebar .nav-item {
    position: relative;
}
.sidebar .fav-star-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--sidebar-text);
    opacity: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: opacity 0.15s, color 0.15s, background-color 0.15s;
    z-index: 2;
}
.sidebar .fav-star-btn i {
    font-size: 0.8rem;
    margin: 0;
    width: auto;
    opacity: 1;
}
.sidebar .nav-item:hover .fav-star-btn {
    opacity: 0.55;
}
.sidebar .fav-star-btn:hover {
    opacity: 1 !important;
    background-color: var(--sidebar-hover);
    color: #f7b500;
}
.sidebar .fav-star-btn.is-fav {
    opacity: 1;
    color: #f7b500;
}
.sidebar .nav-fav-section-label .section-icon {
    color: #f7b500;
}
/* 접힌(아이콘 전용) 사이드바에서는 별 숨김 */
.sidebar.collapsed .fav-star-btn {
    display: none;
}

/* ===== Sidebar Collapsed State ===== */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    min-width: var(--sidebar-collapsed-width);
    max-width: var(--sidebar-collapsed-width);
    overflow: visible;
}

.sidebar.collapsed .sidebar-header h5 span:not(.logo-icon) {
    display: none;
}
.sidebar.collapsed .sidebar-header small {
    display: none;
}
.sidebar.collapsed .sidebar-header {
    padding: 10px 6px 8px;
    text-align: center;
}
.sidebar.collapsed .sidebar-header h5 {
    justify-content: center;
}
.sidebar.collapsed .sidebar-header .logo-icon {
    margin-right: 0;
}

.sidebar.collapsed .nav-section-label {
    justify-content: center;
    padding: 6px 0;
    margin: 2px 4px;
    border-radius: 6px;
}
.sidebar.collapsed .nav-section-label .section-text {
    display: inline-flex;
    justify-content: center;
    width: 100%;
}
.sidebar.collapsed .nav-section-label .section-text > span,
.sidebar.collapsed .nav-section-label .section-chevron {
    display: none;
}
.sidebar.collapsed .nav-section-label .section-icon {
    margin: 0;
    font-size: 0.95rem;
}
.sidebar.collapsed .nav-section-items {
    max-height: 0 !important;
    opacity: 0 !important;
    overflow: hidden;
    pointer-events: none;
    visibility: hidden;
    transform: translateX(-6px) scale(0.985);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

.sidebar.collapsed .nav-sub-label {
    display: none;
}
.sidebar.collapsed .nav-sub-items {
    max-height: 0 !important;
    opacity: 0 !important;
    display: none;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 7px 0;
    margin: 1px 4px;
    position: relative;
    border-left: none;
    padding-left: 0;
}
.sidebar.collapsed .nav-link i {
    margin-right: 0;
    font-size: 0.95rem;
}
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-link .nav-text {
    display: none;
}

/* Tooltip on hover when collapsed */
.sidebar.collapsed .nav-item {
    position: relative;
}
.sidebar.collapsed .nav-item .nav-link::after {
    content: attr(data-title);
    position: absolute;
    left: calc(var(--sidebar-collapsed-width) - 4px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 1100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.sidebar.collapsed .nav-item .nav-link:hover::after {
    opacity: 1;
}

/* Collapsed sidebar: section flyout menu on hover */
.sidebar.collapsed .nav-section-label {
    position: relative;
}
.sidebar.collapsed .nav-section-label:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-hover);
}
.sidebar.collapsed .nav-section-label::after {
    content: none;
    position: absolute;
    left: calc(var(--sidebar-collapsed-width) + 6px);
    top: 50%;
    transform: translateY(-50%);
    background: #0f172a;
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
    text-transform: capitalize;
    z-index: 1150;
    white-space: nowrap;
}
.sidebar.collapsed .nav-section-label:hover::after,
.sidebar.collapsed .nav-section-label.flyout-open::after {
    opacity: 0;
}

.sidebar.collapsed .nav-section-items.hover-open {
    display: block !important;
    position: absolute;
    left: calc(var(--sidebar-collapsed-width) + 2px);
    width: 220px;
    max-height: min(60vh, 420px) !important;
    overflow-y: auto;
    opacity: 1 !important;
    pointer-events: auto;
    z-index: 1200;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 6px 4px;
    visibility: visible;
    transform: translateX(0) scale(1);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0s;
}

.sidebar.collapsed .nav-section-items.hover-open::before {
    content: attr(data-popup-title);
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 4px 8px 6px;
    text-transform: uppercase;
    letter-spacing: 0.35px;
}

/* Invisible hover bridge between section icon and flyout to prevent flicker */
.sidebar.collapsed .nav-section-items.hover-open::after {
    content: '';
    position: absolute;
    left: -10px;
    top: 0;
    width: 12px;
    height: 100%;
    background: transparent;
}

.sidebar.collapsed .nav-section-items.hover-open .nav-link {
    justify-content: flex-start;
    padding: 6px 8px;
    margin: 1px 4px;
    border-left: none;
}
.sidebar.collapsed .nav-section-items.hover-open .nav-link i {
    margin-right: 8px;
    font-size: 0.82rem;
}
.sidebar.collapsed .nav-section-items.hover-open .nav-link span,
.sidebar.collapsed .nav-section-items.hover-open .nav-link .nav-text {
    display: inline !important;
}
.sidebar.collapsed .nav-section-items.hover-open .nav-item .nav-link::after {
    display: none !important;
}
.sidebar.collapsed .nav-section-items.hover-open .nav-sub-label {
    display: none !important;
}
.sidebar.collapsed .nav-section-items.hover-open .nav-sub-items {
    display: block !important;
    max-height: none !important;
    opacity: 1 !important;
}

/* ===== Main content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
    background: var(--bg-body);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}
.main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-height);
    flex: 0 0 var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    padding: 0 18px;
    position: relative;
    top: 0;
    z-index: 999;
    box-shadow: var(--topbar-shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* ===== Global work tabs (opened menus) ===== */
.work-tabs-bar {
    margin: 2px 0 3px;
}
.work-tabs-bar__inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 6px;
    align-items: center;
    background: linear-gradient(180deg, rgba(var(--bs-dark-rgb), 0.04), rgba(var(--bs-dark-rgb), 0.02));
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 5px 7px;
}
.work-tabs-bar__pin {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    flex: 0 0 auto;
}
.work-tabs-bar__pin:empty {
    display: none;
}
.work-tabs-bar__scroll-wrap {
    position: relative;
    min-width: 0;
}
.work-tabs-bar__scroll-wrap::before,
.work-tabs-bar__scroll-wrap::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 18px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .16s ease;
    z-index: 2;
}
.work-tabs-bar__scroll-wrap::before {
    left: 0;
    background: linear-gradient(90deg, var(--bg-card) 20%, rgba(255,255,255,0));
}
.work-tabs-bar__scroll-wrap::after {
    right: 0;
    background: linear-gradient(270deg, var(--bg-card) 20%, rgba(255,255,255,0));
}
.work-tabs-bar__scroll-wrap.show-left-fade::before {
    opacity: 1;
}
.work-tabs-bar__scroll-wrap.show-right-fade::after {
    opacity: 1;
}
.work-tabs-bar__scroll {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--accent-rgb), 0.42) rgba(var(--accent-rgb), 0.08);
    min-height: 36px;
    border-left: 1px dashed rgba(var(--bs-secondary-rgb), 0.18);
    padding-left: 6px;
}
.work-tabs-bar__scroll:empty {
    border-left: 0;
    padding-left: 0;
}
.work-tabs-bar__scroll::-webkit-scrollbar {
    height: 8px;
}
.work-tabs-bar__scroll::-webkit-scrollbar-track {
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.05), rgba(var(--accent-rgb), 0.02));
    border-radius: 999px;
    border: 1px solid rgba(var(--accent-rgb), 0.08);
}
.work-tabs-bar__scroll::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.55), rgba(var(--accent-rgb), 0.38));
    border-radius: 999px;
    border: 1px solid rgba(var(--accent-rgb), 0.2);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}
.work-tabs-bar__scroll::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.72), rgba(var(--accent-rgb), 0.52));
}
.work-tabs-bar__scroll::-webkit-scrollbar-corner {
    background: transparent;
}
.work-tab-chip {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 8px;
    min-width: 0;
    border: 1px solid rgba(var(--bs-secondary-rgb), 0.2);
    background: var(--bg-card);
    color: var(--text-color);
    border-radius: 999px;
    padding: 5px 8px 5px 10px;
    text-decoration: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
    transition: background .14s ease, border-color .14s ease, transform .14s ease;
}
.work-tab-chip:hover {
    background: rgba(var(--bs-primary-rgb), 0.06);
    border-color: rgba(var(--bs-primary-rgb), 0.25);
    color: var(--text-color);
}
.work-tab-chip.active {
    background: linear-gradient(135deg, rgba(var(--bs-danger-rgb), 0.12), rgba(var(--bs-primary-rgb), 0.08));
    border-color: rgba(var(--bs-danger-rgb), 0.35);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.work-tab-chip.is-pinned {
    border-color: rgba(var(--bs-primary-rgb), 0.26);
    background: linear-gradient(135deg, rgba(var(--bs-primary-rgb), 0.10), rgba(var(--bs-info-rgb), 0.06));
}
.work-tab-chip.is-pinned .work-tab-chip__label {
    font-weight: 700;
}
.work-tab-chip__pin {
    width: 16px;
    height: 16px;
    min-width: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.66rem;
    color: var(--bs-primary);
    opacity: 0.9;
}
.work-tab-chip__label {
    min-width: 0;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    font-size: 0.82rem;
    font-weight: 600;
}
.work-tab-chip__close {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 0;
    border-radius: 999px;
    background: rgba(var(--bs-secondary-rgb), 0.12);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.66rem;
    line-height: 1;
}
.work-tab-chip__pin-toggle {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 0;
    border-radius: 999px;
    background: rgba(var(--bs-primary-rgb), 0.08);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.62rem;
    line-height: 1;
}
.work-tab-chip__pin-toggle:hover {
    background: rgba(var(--bs-primary-rgb), 0.16);
    color: var(--bs-primary);
}
.work-tab-chip__pin-toggle.is-active {
    background: rgba(var(--bs-primary-rgb), 0.18);
    color: var(--bs-primary);
}
.work-tabs-bar__nav {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    border: 1px solid rgba(var(--bs-secondary-rgb), 0.12);
    background: rgba(var(--bs-secondary-rgb), 0.03);
    border-radius: 10px;
    padding: 2px;
}
.work-tabs-bar__nav .btn {
    width: 26px;
    height: 26px;
    min-width: 26px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--text-muted);
}
.work-tabs-bar__nav .btn:hover {
    background: rgba(var(--bs-primary-rgb), 0.06);
    color: var(--bs-primary);
}
.work-tabs-bar__nav .btn:disabled {
    opacity: 0.35;
    cursor: default;
}
.work-tab-chip__close:hover {
    background: rgba(var(--bs-danger-rgb), 0.16);
    color: var(--bs-danger);
}
/* 탭 드래그 앤 드롭 */
.work-tab-chip[draggable="true"] { cursor: grab; }
.work-tab-chip[draggable="true"]:active { cursor: grabbing; }
.work-tab-chip.is-dragging { opacity: 0.35; }
.work-tab-chip.drag-over-left { box-shadow: inset 3px 0 0 var(--accent); }
.work-tab-chip.drag-over-right { box-shadow: inset -3px 0 0 var(--accent); }
.work-tabs-bar__actions .btn {
    white-space: nowrap;
    font-size: 0.72rem;
    padding: 3px 6px;
    border-radius: 10px;
    line-height: 1.1;
    color: var(--text-muted);
}
.work-tabs-bar__actions .btn:hover {
    color: var(--bs-danger);
    background: rgba(var(--bs-danger-rgb), 0.06);
}
.work-tabs-bar__actions .btn i {
    font-size: 0.86rem;
}
[data-theme="dark"] .work-tabs-bar__scroll-wrap::before {
    background: linear-gradient(90deg, #0f172a 20%, rgba(15,23,42,0));
}
[data-theme="dark"] .work-tabs-bar__scroll-wrap::after {
    background: linear-gradient(270deg, #0f172a 20%, rgba(15,23,42,0));
}
[data-theme="dark"] .work-tabs-bar__scroll {
    scrollbar-color: rgba(var(--accent-rgb), 0.55) rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .work-tabs-bar__scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.07);
}
[data-theme="dark"] .work-tabs-bar__scroll::-webkit-scrollbar-thumb {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
[data-theme="dark"] .content-area > .content-scroll {
    scrollbar-color: rgba(var(--accent-rgb), 0.50) rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .content-area > .content-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
}
[data-theme="dark"] .content-area > .content-scroll::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.60), rgba(var(--accent-rgb), 0.40));
    border-color: rgba(255, 255, 255, 0.08);
}
@media (max-width: 991px) {
    .work-tabs-bar__inner {
        grid-template-columns: 1fr;
    }
    .work-tabs-bar__pin {
        order: 1;
    }
    .work-tabs-bar__scroll {
        order: 2;
        border-left: 0;
        padding-left: 0;
    }
    .work-tabs-bar__scroll-wrap::before,
    .work-tabs-bar__scroll-wrap::after {
        width: 12px;
    }
    .work-tabs-bar__nav {
        order: 3;
        justify-self: end;
    }
    .work-tabs-bar__actions {
        order: 4;
        display: flex;
        justify-content: flex-end;
    }
}

/* Local content-tabs are still useful for multi-grid pages (e.g. NCR/CAPA, inspections screens).
   Keep them visible, but make them visually lighter under the global work tabs bar. */
.content-area > .content-tabs {
    margin-top: 2px;
    margin-bottom: 8px;
}
.content-area > .content-tabs .tab-nav {
    padding: 4px;
    border-radius: 10px;
    background: rgba(var(--bs-secondary-rgb), 0.06);
    border: 1px solid rgba(var(--bs-secondary-rgb), 0.08);
    box-shadow: none;
}
.content-area > .content-tabs .tab-nav a {
    padding: 6px 11px;
    border-radius: 8px;
    font-size: 0.8rem;
}
.content-area > .content-tabs .tab-nav a.active {
    box-shadow: none;
}

.topbar .user-info {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.topbar .user-info .user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.topbar .btn-outline-secondary {
    color: var(--text-muted);
    border-color: transparent;
}
.topbar .btn-outline-secondary:hover {
    color: var(--text-primary);
    background: var(--accent-soft);
    border-color: transparent;
}

.topbar .site-dropdown .btn {
    font-size: 0.78rem;
}

.topbar .site-dropdown .dropdown-menu {
    font-size: 0.82rem;
}

.topbar .user-info-dropdown .dropdown-menu {
    font-size: 0.82rem;
}

/* Theme Selector */
.theme-dropdown .dropdown-menu {
    min-width: 180px;
    padding: 6px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    border-radius: 10px;
    background: var(--bg-card);
}
.theme-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-secondary);
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.theme-option:hover {
    background: var(--accent-soft);
    color: var(--text-primary);
}
.theme-option.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}
.theme-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}
.theme-option.active .theme-swatch {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ===== Cards ===== */
.card {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease, background-color 0.3s;
    background: var(--bg-card);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: var(--bg-card-header);
    border-bottom: 1px solid var(--border-light);
    padding: 10px 14px;
    border-radius: 8px 8px 0 0 !important;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-primary);
}

.card-body {
    padding: 14px;
}

/* ===== Stat Cards (Dashboard) ===== */
.stat-card {
    border-left: 3px solid;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.04;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card .card-body {
    padding: 12px 14px;
}

.stat-card h6 {
    font-size: 0.68rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.stat-card h3 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0;
    color: var(--text-heading);
}

.stat-card .stat-icon {
    font-size: 1.6rem;
    opacity: 0.15;
}

.stat-card .stat-link {
    font-size: 0.7rem;
    font-weight: 500;
    opacity: 0.75;
    transition: opacity 0.2s;
}
.stat-card .stat-link:hover {
    opacity: 1;
}

/* ===== Tables ===== */
.table {
    margin-bottom: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.table thead th {
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    background: var(--bg-table-header);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 10px;
    white-space: nowrap;
}

.table tbody td {
    padding: 7px 10px;
    vertical-align: middle;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

.table-hover tbody tr:hover {
    background-color: var(--bg-table-hover);
}

.table tbody td a {
    font-weight: 500;
}

/* ===== Badges ===== */
.badge {
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.7rem;
    letter-spacing: 0.2px;
}

/* ===== Buttons ===== */
.btn {
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.78rem;
    padding: 5px 14px;
    transition: all 0.15s ease;
}

.btn:focus-visible {
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-sm {
    font-size: 0.72rem;
    padding: 3px 10px;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.btn-primary:hover {
    filter: brightness(0.9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.btn-warning {
    color: #fff;
    background: #f59e0b;
    border-color: #f59e0b;
}
.btn-warning:hover {
    color: #fff;
    background: #d97706;
}

.btn-danger {
    box-shadow: 0 1px 2px rgba(239, 68, 68, 0.15);
}

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-muted);
}
.btn-outline-secondary:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline-danger {
    font-size: 0.75rem;
    padding: 3px 10px;
}

/* ===== Forms ===== */
.form-control, .form-select {
    border-radius: 6px;
    border: 1px solid var(--border-color);
    padding: 7px 12px;
    font-size: 0.82rem;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23475569' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    padding-right: 28px;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
    background-size: 12px 10px !important;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: var(--bg-input);
    color: var(--text-primary);
}

.form-control-sm, .form-select-sm {
    padding: 4px 8px;
    font-size: 0.78rem;
}

.form-label {
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* ===== Page titles ===== */
h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-heading);
}

/* ===== Content area ===== */
.content-area {
    padding: 0 14px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.content-area > .work-tabs-bar {
    flex: 0 0 auto;
}
.content-area > .content-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding-top: 8px;
    padding-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--accent-rgb), 0.45) rgba(var(--accent-rgb), 0.08);
    /* 페이지 전환 페이드 효과 */
    opacity: 0;
    transition: opacity 0.18s ease;
}
.content-area > .content-scroll.is-visible {
    opacity: 1;
}
.content-area > .content-scroll::-webkit-scrollbar {
    width: 8px;
}
.content-area > .content-scroll::-webkit-scrollbar-track {
    background: rgba(var(--accent-rgb), 0.06);
    border-radius: 999px;
}
.content-area > .content-scroll::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.55), rgba(var(--accent-rgb), 0.35));
    border-radius: 999px;
    border: 1px solid rgba(var(--accent-rgb), 0.15);
}
.content-area > .content-scroll::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.72), rgba(var(--accent-rgb), 0.50));
}

.content-area.content-area--scrollable > .content-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

/* Split-layout 페이지에서 content-scroll도 flex column으로 확장 */
.content-area[class*="-split-layout"] > .content-scroll {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
}

/* ===== Login page ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--login-gradient);
}

.login-card {
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    width: 100%;
    max-width: 380px;
}

.login-card .logo-wrapper {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--logo-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.login-card .logo-wrapper i {
    font-size: 1.5rem;
    color: #fff;
}

.login-system-name {
    color: #1e293b;
}

/* ===== Toast Notifications ===== */
.qms-toast-container {
    position: fixed;
    top: 12px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 380px;
    pointer-events: none;
}
.qms-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    line-height: 1.45;
    background: #fff;
    color: #1e293b;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.08);
    border-left: 3px solid;
    position: relative;
    overflow: hidden;
    animation: qmsToastIn 0.3s ease;
}
.qms-toast.qms-toast--removing {
    animation: qmsToastOut 0.35s ease forwards;
}
.qms-toast__icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 1px;
}
.qms-toast__body {
    flex: 1;
    word-break: keep-all;
}
.qms-toast__close {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.45;
    cursor: pointer;
    padding: 0;
    font-size: 0.75rem;
    flex-shrink: 0;
    margin-top: 1px;
}
.qms-toast__close:hover { opacity: 0.8; }
.qms-toast__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    animation: qmsToastProgress 4s linear forwards;
}

/* Toast color variants */
.qms-toast--success { border-left-color: #10b981; }
.qms-toast--success .qms-toast__icon { color: #10b981; }
.qms-toast--success .qms-toast__progress { background: #10b981; }

.qms-toast--danger { border-left-color: #ef4444; }
.qms-toast--danger .qms-toast__icon { color: #ef4444; }
.qms-toast--danger .qms-toast__progress { background: #ef4444; }

.qms-toast--warning { border-left-color: #f59e0b; }
.qms-toast--warning .qms-toast__icon { color: #f59e0b; }
.qms-toast--warning .qms-toast__progress { background: #f59e0b; }

.qms-toast--info { border-left-color: #3b82f6; }
.qms-toast--info .qms-toast__icon { color: #3b82f6; }
.qms-toast--info .qms-toast__progress { background: #3b82f6; }

@keyframes qmsToastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes qmsToastOut {
    from { opacity: 1; transform: translateX(0); max-height: 100px; margin-bottom: 0; }
    to   { opacity: 0; transform: translateX(40px); max-height: 0; margin-bottom: -8px; padding-top: 0; padding-bottom: 0; }
}
@keyframes qmsToastProgress {
    from { width: 100%; }
    to   { width: 0%; }
}

/* ===== Legacy Alerts (for modals / inline) ===== */
.alert {
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    padding: 10px 16px;
    border-left: 3px solid;
}
.alert-success {
    border-left-color: #10b981;
}
.alert-danger {
    border-left-color: #ef4444;
}
.alert-warning {
    border-left-color: #f59e0b;
}
.alert-info {
    border-left-color: #3b82f6;
}

/* ===== Pagination ===== */
.page-link {
    border-radius: 6px !important;
    margin: 0 2px;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.78rem;
    padding: 4px 10px;
    transition: all 0.15s ease;
}
.page-link:hover {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}
.page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ===== Content Tabs ===== */
.content-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.content-tabs .tab-nav {
    display: flex;
    gap: 2px;
    background: var(--border-color);
    border-radius: 8px;
    padding: 3px;
}
.content-tabs .tab-nav a {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.content-tabs .tab-nav a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.5);
}
.content-tabs .tab-nav a.active {
    background: var(--bg-card);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.content-tabs .tab-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ===== Detail page tables ===== */
.table-bordered th {
    background: var(--bg-table-header);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 7px 10px;
}
.table-bordered td {
    font-size: 0.82rem;
    padding: 7px 10px;
    color: var(--text-secondary);
}

/* ===== Scrollbar ===== */
.sidebar > .nav::-webkit-scrollbar {
    width: 6px;
}
.sidebar > .nav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.08);
}
.sidebar > .nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.50);
    border-radius: 3px;
}
.sidebar > .nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.70);
}

/* ===== Notification Dropdown ===== */
.notification-dropdown {
    padding: 0;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    border-radius: 10px;
    background: var(--bg-card);
}
.notification-dropdown .dropdown-header {
    background: var(--bg-table-header);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 14px;
    font-size: 0.78rem;
}
.notification-dropdown .dropdown-item {
    font-size: 0.78rem;
    white-space: normal;
    padding: 8px 14px;
    color: var(--text-secondary);
}
.notification-dropdown .dropdown-item:hover {
    background: var(--accent-soft);
}

/* ===== Approval Timeline ===== */
.approval-timeline .timeline-item {
    padding-left: 4px;
}
.approval-timeline .timeline-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}
.approval-timeline .timeline-content {
    line-height: 1.4;
}

/* ===== Audit Trail Table ===== */
.table del {
    color: #ef4444;
    background: #fef2f2;
    padding: 0 3px;
    border-radius: 3px;
}
.table ins {
    color: #22c55e;
    background: #f0fdf4;
    padding: 0 3px;
    border-radius: 3px;
    text-decoration: none;
}

/* ===== List Group (Notifications) ===== */
.list-group-item {
    font-size: 0.82rem;
    border-color: var(--border-light);
    background: var(--bg-card);
    color: var(--text-secondary);
}
.list-group-item-action:hover {
    background: var(--accent-soft);
}

/* ===== Dark theme specific overrides ===== */

/* --- 텍스트 드래그 선택 영역 (다크 모드 전역) --- */
[data-theme="dark"] ::selection {
    background: rgba(96, 165, 250, 0.40);
    color: #fff;
}
[data-theme="dark"] ::-moz-selection {
    background: rgba(96, 165, 250, 0.40);
    color: #fff;
}

/* --- Base elements --- */
[data-theme="dark"] .card {
    border-color: #334155;
}
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6,
[data-theme="dark"] .card-title,
[data-theme="dark"] .card-header h6 {
    color: #f1f5f9;
}
[data-theme="dark"] p,
[data-theme="dark"] span,
[data-theme="dark"] div {
    color: inherit;
}
[data-theme="dark"] .stat-card h3 {
    color: #f1f5f9;
}

/* --- Bootstrap utility class overrides --- */
[data-theme="dark"] .bg-light {
    background-color: #1e293b !important;
}
[data-theme="dark"] .bg-light-subtle {
    background-color: rgba(255, 255, 255, 0.05) !important;
}
[data-theme="dark"] .bg-white {
    background-color: #1e293b !important;
}
[data-theme="dark"] .bg-body {
    background-color: #0f172a !important;
}
[data-theme="dark"] .bg-body-secondary {
    background-color: #1e293b !important;
}
[data-theme="dark"] .bg-body-tertiary {
    background-color: #1e293b !important;
}
[data-theme="dark"] .text-dark {
    color: #e2e8f0 !important;
}
[data-theme="dark"] .text-body {
    color: #e2e8f0 !important;
}
[data-theme="dark"] .text-muted {
    color: #64748b !important;
}
[data-theme="dark"] .text-black {
    color: #e2e8f0 !important;
}
[data-theme="dark"] .text-black-50 {
    color: #94a3b8 !important;
}
[data-theme="dark"] .border {
    border-color: #334155 !important;
}
[data-theme="dark"] .border-bottom {
    border-color: #334155 !important;
}
[data-theme="dark"] .border-top {
    border-color: #334155 !important;
}

/* --- Tables --- */
[data-theme="dark"] .table-bordered {
    border-color: #334155;
}
[data-theme="dark"] .table-bordered th,
[data-theme="dark"] .table-bordered td {
    border-color: #334155;
}
[data-theme="dark"] .table {
    color: #cbd5e1;
}
[data-theme="dark"] .table > :not(caption) > * > * {
    background-color: transparent;
    color: #cbd5e1;
}
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(255, 255, 255, 0.02);
    color: #cbd5e1;
}
[data-theme="dark"] .table del {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}
[data-theme="dark"] .table ins {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
}

/* --- Badges --- */
[data-theme="dark"] .badge.bg-light {
    background: #334155 !important;
    color: #e2e8f0 !important;
}
[data-theme="dark"] .badge.bg-secondary {
    background: #475569 !important;
    color: #e2e8f0 !important;
}
[data-theme="dark"] .badge.bg-info {
    background: rgba(14, 165, 233, 0.2) !important;
    color: #7dd3fc !important;
}
[data-theme="dark"] .badge.bg-warning {
    background: rgba(245, 158, 11, 0.2) !important;
    color: #fcd34d !important;
}
[data-theme="dark"] .badge.bg-danger {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #fca5a5 !important;
}
[data-theme="dark"] .badge.bg-success {
    background: rgba(16, 185, 129, 0.2) !important;
    color: #6ee7b7 !important;
}
[data-theme="dark"] .badge.bg-primary {
    background: rgba(139, 92, 246, 0.25) !important;
    color: #c4b5fd !important;
}
[data-theme="dark"] .badge.text-dark {
    color: inherit !important;
}

/* --- ops-badge dark adjustments --- */
[data-theme="dark"] .ops-badge.is-danger { color: #fca5a5; background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.25); }
[data-theme="dark"] .ops-badge.is-warning { color: #fcd34d; background: rgba(245, 158, 11, 0.15); border-color: rgba(245, 158, 11, 0.25); }
[data-theme="dark"] .ops-badge.is-success { color: #6ee7b7; background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.25); }
[data-theme="dark"] .ops-badge.is-info { color: #7dd3fc; background: rgba(14, 165, 233, 0.15); border-color: rgba(14, 165, 233, 0.25); }
[data-theme="dark"] .ops-badge.is-neutral { color: #cbd5e1; background: rgba(148, 163, 184, 0.12); border-color: rgba(148, 163, 184, 0.2); }

/* --- Toast dark --- */
[data-theme="dark"] .qms-toast {
    background: #1e293b;
    color: #e2e8f0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.35), 0 1px 4px rgba(0,0,0,0.25);
}
[data-theme="dark"] .qms-toast--success { border-left-color: #34d399; }
[data-theme="dark"] .qms-toast--success .qms-toast__icon { color: #34d399; }
[data-theme="dark"] .qms-toast--danger { border-left-color: #f87171; }
[data-theme="dark"] .qms-toast--danger .qms-toast__icon { color: #f87171; }
[data-theme="dark"] .qms-toast--warning { border-left-color: #fbbf24; }
[data-theme="dark"] .qms-toast--warning .qms-toast__icon { color: #fbbf24; }
[data-theme="dark"] .qms-toast--info { border-left-color: #60a5fa; }
[data-theme="dark"] .qms-toast--info .qms-toast__icon { color: #60a5fa; }

/* --- Alerts (inline, modals) --- */
[data-theme="dark"] .alert {
    color: #e2e8f0;
}
[data-theme="dark"] .alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-left-color: #10b981;
    color: #6ee7b7;
}
[data-theme="dark"] .alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-left-color: #ef4444;
    color: #fca5a5;
}
[data-theme="dark"] .alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-left-color: #f59e0b;
    color: #fcd34d;
}
[data-theme="dark"] .alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: #3b82f6;
    color: #93c5fd;
}

/* --- Modals --- */
[data-theme="dark"] .modal-content {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}
[data-theme="dark"] .modal-header {
    border-color: #334155;
    color: #f1f5f9;
}
[data-theme="dark"] .modal-footer {
    border-color: #334155;
}
[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* --- Dropdowns --- */
[data-theme="dark"] .dropdown-menu {
    background: #1e293b;
    border-color: #334155;
}
[data-theme="dark"] .dropdown-item {
    color: #cbd5e1;
}
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background: rgba(139, 92, 246, 0.15);
    color: #e2e8f0;
}
[data-theme="dark"] .dropdown-divider {
    border-color: #334155;
}
[data-theme="dark"] .dropdown-header {
    color: #94a3b8;
}

/* --- Buttons --- */
[data-theme="dark"] .btn-secondary {
    background: #475569;
    border-color: #475569;
    color: #e2e8f0;
}
[data-theme="dark"] .btn-secondary:hover {
    background: #64748b;
    border-color: #64748b;
    color: #f1f5f9;
}
[data-theme="dark"] .btn-outline-secondary {
    color: #94a3b8;
    border-color: #475569;
}
[data-theme="dark"] .btn-outline-secondary:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--accent);
    color: var(--accent-light);
}
[data-theme="dark"] .btn-outline-danger {
    color: #fca5a5;
    border-color: #fca5a5;
}
[data-theme="dark"] .btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border-color: #fca5a5;
}
[data-theme="dark"] .btn-light {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}
[data-theme="dark"] .btn-light:hover {
    background: #475569;
    border-color: #64748b;
    color: #f1f5f9;
}

/* --- Forms --- */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: #0f172a;
    color: #e2e8f0;
    border-color: #334155;
}
[data-theme="dark"] .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: #0f172a;
    color: #e2e8f0;
    border-color: var(--accent);
}
[data-theme="dark"] .form-control::placeholder {
    color: #64748b;
}
[data-theme="dark"] .form-control:disabled,
[data-theme="dark"] .form-control[readonly],
[data-theme="dark"] .form-select:disabled {
    background-color: #1e293b;
    color: #94a3b8;
}
[data-theme="dark"] .form-check-input {
    background-color: #0f172a;
    border-color: #475569;
}
[data-theme="dark"] .form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}
[data-theme="dark"] .form-text {
    color: #64748b;
}
[data-theme="dark"] .input-group-text {
    background-color: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}
[data-theme="dark"] select option {
    background: #1e293b;
    color: #e2e8f0;
}

/* --- List group --- */
[data-theme="dark"] .list-group-item {
    background-color: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}
[data-theme="dark"] .list-group-item-action:hover {
    background-color: rgba(139, 92, 246, 0.1);
    color: #e2e8f0;
}

/* --- Pagination --- */
[data-theme="dark"] .page-link {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}
[data-theme="dark"] .page-link:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--accent);
    color: var(--accent-light);
}
[data-theme="dark"] .page-item.disabled .page-link {
    background: #0f172a;
    border-color: #1e293b;
    color: #475569;
}

/* --- Breadcrumb --- */
[data-theme="dark"] .breadcrumb-item + .breadcrumb-item::before {
    color: #64748b;
}
[data-theme="dark"] .breadcrumb-item.active {
    color: #94a3b8;
}

/* --- Progress bar --- */
[data-theme="dark"] .progress {
    background-color: #334155;
}

/* --- Content text blocks (border rounded p-3 bg-light etc.) --- */
[data-theme="dark"] .border.rounded.p-3 {
    background-color: rgba(255, 255, 255, 0.04) !important;
    border-color: #334155 !important;
    color: #cbd5e1;
}

/* --- Content tabs --- */
[data-theme="dark"] .content-tabs .tab-nav {
    background: #334155;
}
[data-theme="dark"] .content-tabs .tab-nav a {
    color: #94a3b8;
}
[data-theme="dark"] .content-tabs .tab-nav a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}
[data-theme="dark"] .content-tabs .tab-nav a.active {
    background: #1e293b;
    color: var(--accent-light);
}

/* --- Stat card / text color utilities --- */
[data-theme="dark"] .text-danger {
    color: #fca5a5 !important;
}
[data-theme="dark"] .text-warning {
    color: #fcd34d !important;
}
[data-theme="dark"] .text-success {
    color: #6ee7b7 !important;
}
[data-theme="dark"] .text-info {
    color: #7dd3fc !important;
}
[data-theme="dark"] .text-primary {
    color: #c4b5fd !important;
}
[data-theme="dark"] .text-secondary {
    color: #94a3b8 !important;
}

/* --- Card with bg-light for stats (review_detail pattern) --- */
[data-theme="dark"] .card.bg-light {
    background-color: #0f172a !important;
    border-color: #334155;
}
[data-theme="dark"] .card.bg-light .card-body {
    color: #cbd5e1;
}
[data-theme="dark"] .card.text-center.bg-light .fs-4 {
    color: inherit;
}

/* --- ops table toolbar gradient fix (dark uses CSS variable from theme) --- */

/* --- Tooltip / Popover --- */
[data-theme="dark"] .tooltip-inner {
    background: #334155;
    color: #f1f5f9;
}
[data-theme="dark"] .popover {
    background: #1e293b;
    border-color: #334155;
}
[data-theme="dark"] .popover-body {
    color: #cbd5e1;
}

/* --- Accordion --- */
[data-theme="dark"] .accordion-item {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}
[data-theme="dark"] .accordion-button {
    background: #1e293b;
    color: #e2e8f0;
}
[data-theme="dark"] .accordion-button:not(.collapsed) {
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-light);
}
[data-theme="dark"] .accordion-button::after {
    filter: invert(1);
}

/* --- Login page dark --- */
[data-theme="dark"] .login-card {
    background: #1e293b;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .login-card .card-body {
    background: #1e293b;
    color: #e2e8f0;
}
[data-theme="dark"] .login-system-name {
    color: #e2e8f0;
}

/* --- hr / separator --- */
[data-theme="dark"] hr {
    border-color: #334155;
    opacity: 0.5;
}

/* --- Misc small elements --- */
[data-theme="dark"] .small, [data-theme="dark"] small {
    color: inherit;
}
[data-theme="dark"] code {
    color: #f0abfc;
    background: rgba(139, 92, 246, 0.1);
}
[data-theme="dark"] pre {
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
}
[data-theme="dark"] .form-label {
    color: #94a3b8;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
    }
    .sidebar.active {
        margin-left: 0;
    }
    .sidebar.collapsed {
        margin-left: calc(-1 * var(--sidebar-collapsed-width));
    }
    .sidebar.collapsed.active {
        margin-left: 0;
    }
    .main-content,
    .main-content.expanded {
        margin-left: 0;
    }
    .content-area {
        padding: 0 12px;
    }
    .content-area > .content-scroll {
        padding-top: 8px;
        padding-bottom: 8px;
    }
}

/* ===== Dense Ops UI (Phase 1 Redesign) ===== */
:root,
[data-theme="indigo"],
[data-theme="ocean"],
[data-theme="forest"],
[data-theme="rose"],
[data-theme="dark"] {
    --density-row-height: 32px;
    --density-cell-px: 8px;
    --density-toolbar-height: 28px;
    --table-sticky-header-bg: var(--bg-table-header);
    --table-grid-border: var(--border-light);
    --status-open: #ef4444;
    --status-warning: #f59e0b;
    --status-success: #10b981;
    --status-danger: #dc2626;
    --status-neutral: #64748b;
    --status-info: #0ea5e9;
    --kpi-card-radius: 10px;
    --kpi-card-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
    --panel-radius: 10px;
    --font-size-xs: 11px;
    --font-size-sm: 12px;
    --font-size-md: 13px;
}

body.ui-density-dense {
    font-size: var(--font-size-md);
}

.content-area {
    padding-top: 2px;
}
.content-area > .content-scroll {
    padding-top: 6px;
}

/* ── 모달 헤더 컴팩트 ── */
#globalContentModal .modal-header {
    padding: 0.2rem 0.75rem;
    min-height: 0;
}
#globalContentModal .modal-header .modal-title {
    font-size: 0.85rem;
}
#globalContentModal .modal-header .btn-close {
    padding: 0.2rem;
}
#globalContentModal .modal-header #modalBackBtn {
    padding: 0.1rem 0.3rem;
    font-size: 0.75rem;
}

/* ── 모달 스크롤바 테마 ── */
#globalContentModal .modal-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--accent-rgb), 0.45) rgba(var(--accent-rgb), 0.08);
}
#globalContentModal .modal-body::-webkit-scrollbar {
    width: 8px;
}
#globalContentModal .modal-body::-webkit-scrollbar-track {
    background: rgba(var(--accent-rgb), 0.06);
    border-radius: 999px;
}
#globalContentModal .modal-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.55), rgba(var(--accent-rgb), 0.35));
    border-radius: 999px;
    border: 1px solid rgba(var(--accent-rgb), 0.15);
}
#globalContentModal .modal-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.72), rgba(var(--accent-rgb), 0.50));
}
[data-theme="dark"] #globalContentModal .modal-body {
    scrollbar-color: rgba(var(--accent-rgb), 0.50) rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] #globalContentModal .modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
}
[data-theme="dark"] #globalContentModal .modal-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.60), rgba(var(--accent-rgb), 0.40));
    border-color: rgba(255, 255, 255, 0.08);
}

#globalContentModalBody .modal-content-frame {
    width: 100%;
    height: min(76vh, 900px);
    border: 0;
    display: block;
    background: var(--bg-card);
}

.topbar {
    min-height: var(--topbar-height);
    gap: 8px;
}

.topbar-search-slot {
    margin-left: 8px;
    min-width: 280px;
    flex: 1 1 auto;
    max-width: 520px;
}

.topbar-search-box {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 34px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 8px;
    padding: 0 8px 0 10px;
    color: var(--text-muted);
    font-size: 0.78rem;
    box-shadow: var(--shadow-sm);
}

.topbar-search-box:focus-within {
    border-color: rgba(var(--accent-rgb), 0.35);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.10);
}

.topbar-search-icon {
    color: var(--text-muted);
    margin-right: 6px;
    font-size: 0.86rem;
}

.topbar-search-input {
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    background: transparent;
    outline: none;
    color: var(--text-primary);
    font-size: 0.78rem;
    line-height: 1;
}

.topbar-search-input::placeholder {
    color: var(--text-muted);
}

.topbar-search-clear {
    border: none;
    background: transparent;
    color: var(--text-muted);
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.topbar-search-clear:hover {
    background: var(--accent-soft);
    color: var(--text-primary);
}

.topbar-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 1105;
    overflow: hidden;
}

.topbar-search-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-table-header);
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.topbar-search-dropdown-header small {
    color: var(--text-muted);
}

.topbar-search-results {
    max-height: 360px;
    overflow-y: auto;
    padding: 4px;
}

.topbar-search-group + .topbar-search-group {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed var(--border-light);
}

.topbar-search-group__label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    padding: 4px 8px 3px;
}

.topbar-search-group__label span {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: none;
}

.topbar-search-recent {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 8px 8px;
}

.topbar-search-recent__chip {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 0.72rem;
    line-height: 1.1;
    transition: all 0.15s ease;
}

.topbar-search-recent__chip:hover {
    border-color: var(--accent-soft-border);
    background: var(--accent-soft);
    color: var(--text-primary);
}

.topbar-search-shortcuts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 4px 8px 8px;
}

.topbar-search-shortcut {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 7px 8px;
    font-size: 0.73rem;
    line-height: 1.1;
}

.topbar-search-shortcut i {
    color: var(--accent);
    flex: 0 0 auto;
}

.topbar-search-shortcut span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-search-shortcut:hover {
    border-color: var(--accent-soft-border);
    background: var(--accent-soft);
    color: var(--text-primary);
}

.topbar-search-empty {
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 10px 10px;
}

.topbar-search-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 9px;
    border-radius: 8px;
    color: inherit;
    border: 1px solid transparent;
}

.topbar-search-item:hover,
.topbar-search-item.is-active {
    background: var(--accent-soft);
    border-color: var(--accent-soft-border);
    color: inherit;
}

.topbar-search-item__badge {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 0.66rem;
    line-height: 1.2;
    font-weight: 700;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.10);
    border: 1px solid rgba(var(--accent-rgb), 0.20);
    margin-top: 1px;
}

.topbar-search-item__body {
    min-width: 0;
    flex: 1 1 auto;
}

.topbar-search-item__title {
    color: var(--text-primary);
    font-size: 0.76rem;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-search-item__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-search-item__meta .num {
    color: var(--text-secondary);
    font-weight: 600;
}

.topbar-search-item__open {
    flex: 0 0 auto;
    color: var(--text-muted);
    margin-top: 2px;
}

.topbar-tools {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
}

.topbar-tools .btn {
    border-radius: 6px;
}


.topbar-counter-badge {
    top: 2px !important;
    right: 2px !important;
    left: auto !important;
    transform: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 14px;
    height: 14px;
    padding: 0 4px;
    border-radius: 999px;
    font-size: 0.56rem;
    line-height: 1;
    font-weight: 700;
    box-shadow: 0 0 0 1px var(--topbar-bg);
    z-index: 2;
}
[data-theme="dark"] .topbar-counter-badge {
    box-shadow: 0 0 0 1px #1e293b;
}

.user-info {
    max-width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8rem;
}

.user-info .user-name {
    max-width: 130px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}

.user-info .user-dept {
    white-space: nowrap;
}


.ops-tabs.content-tabs {
    margin-bottom: 8px;
}

.ops-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}

.ops-page-header__title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.01em;
}
.ops-page-header__help {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-left: 6px;
    vertical-align: middle;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s;
    text-decoration: none;
}
.ops-page-header__help:hover {
    opacity: 1;
    color: var(--primary);
}

.ops-page-header__subtitle {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.ops-page-header__actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ops-date-chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.74rem;
    color: var(--text-secondary);
}

.ops-summary-strip {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.ops-metric-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 0.68rem;
    color: var(--text-secondary);
}

.ops-metric-chip .label {
    color: var(--text-muted);
}

.ops-metric-chip strong {
    color: var(--text-heading);
    font-size: 0.7rem;
}

.ops-metric-chip.is-danger { border-color: rgba(239, 68, 68, 0.25); background: rgba(239, 68, 68, 0.04); }
.ops-metric-chip.is-warning { border-color: rgba(245, 158, 11, 0.25); background: rgba(245, 158, 11, 0.05); }
.ops-metric-chip.is-success { border-color: rgba(16, 185, 129, 0.25); background: rgba(16, 185, 129, 0.05); }
.ops-metric-chip.is-info { border-color: rgba(14, 165, 233, 0.25); background: rgba(14, 165, 233, 0.05); }
.ops-metric-chip.is-neutral { border-color: rgba(100, 116, 139, 0.25); background: rgba(100, 116, 139, 0.04); }
.ops-metric-chip.is-clickable { cursor: pointer; transition: transform .08s ease, box-shadow .12s ease, border-color .12s ease; }
.ops-metric-chip.is-clickable:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.ops-metric-chip.is-clickable:focus-visible { outline: 2px solid var(--accent-soft-focus); outline-offset: 2px; }
.ops-metric-chip.is-active { border-color: var(--accent-soft-border); box-shadow: inset 0 0 0 1px var(--accent-soft-hover); }

.ops-filter-card,
.ops-panel {
    border-radius: var(--panel-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.ops-filter-card .card-body {
    background: var(--bg-card);
    padding: 4px 10px !important;
}

.ops-filter-grid {
    display: grid;
    grid-template-columns: 2.1fr repeat(7, minmax(120px, 1fr)) auto;
    gap: 6px;
    align-items: end;
}

.ops-field .form-label {
    color: var(--text-muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 1px !important;
}

.ops-field .form-control,
.ops-field .form-select {
    min-height: 28px;
    font-size: 0.74rem;
    padding: 2px 8px;
    border-radius: 7px;
    border-color: var(--border-color);
    background: var(--bg-input);
}

.ops-field--search {
    min-width: 220px;
}

.ops-filter-actions {
    min-width: 132px;
}

.ops-table-toolbar {
    min-height: var(--density-toolbar-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 10px;
    border-bottom: 1px solid var(--table-grid-border);
    background: linear-gradient(180deg, var(--toolbar-gradient-overlay), transparent) , var(--bg-card);
    border-top-left-radius: var(--panel-radius);
    border-top-right-radius: var(--panel-radius);
}

.ops-table-toolbar__left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.74rem;
}

.ops-table-toolbar__count strong {
    color: var(--text-heading);
}

.ops-table-shell {
    max-height: clamp(320px, calc(100vh - 270px), 72vh);
    min-height: 220px;
    overflow: auto;
    position: relative;
    border-bottom-left-radius: var(--panel-radius);
    border-bottom-right-radius: var(--panel-radius);
    isolation: isolate;
    overscroll-behavior-y: contain;
    overscroll-behavior-x: contain;
    scrollbar-gutter: stable both-edges;
    -webkit-overflow-scrolling: touch;
}

.ops-table-shell--compact {
    max-height: 260px;
}

.ops-table-shell {
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--accent-rgb), 0.55) rgba(var(--accent-rgb), 0.12);
}

.ops-table-shell::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.ops-table-shell::-webkit-scrollbar-track {
    background: rgba(var(--accent-rgb), 0.1);
    border-radius: 10px;
}

.ops-table-shell::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.72), rgba(var(--accent-rgb), 0.5));
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.ops-table-shell::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.86), rgba(var(--accent-rgb), 0.6));
}

.ops-table-shell::-webkit-scrollbar-corner {
    background: transparent;
}

.ops-data-table {
    margin-bottom: 0;
    white-space: nowrap;
    border-collapse: separate;
    border-spacing: 0;
}

.ops-data-table thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    background: var(--table-sticky-header-bg);
    border-bottom: 1px solid var(--border-color);
    background-clip: padding-box;
    color: var(--text-muted);
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 4px var(--density-cell-px);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Use thead-level sticky inside scroll shells to avoid header/body overlap in some browsers */
.ops-table-shell .ops-data-table thead {
    position: sticky;
    top: 0;
    z-index: 6;
    background: var(--table-sticky-header-bg);
}

.ops-table-shell .ops-data-table thead th {
    position: static;
    top: auto;
    z-index: auto;
    background: transparent;
    box-shadow: inset 0 -1px 0 var(--table-grid-border);
}

/* ── Column resize handle ── */
.col-resize-handle {
    position: absolute;
    right: -3px;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 10;
    user-select: none;
}
.col-resize-handle::after {
    content: "";
    position: absolute;
    right: 2px;
    top: 25%;
    bottom: 25%;
    width: 2px;
    border-radius: 1px;
    background: transparent;
    transition: background 0.15s;
}
.col-resize-handle:hover::after,
.col-resize-handle.is-dragging::after {
    background: rgba(var(--accent-rgb), 0.6);
}
.col-resize-handle.is-dragging::after {
    top: 0;
    bottom: 0;
    background: rgba(var(--accent-rgb), 0.8);
}
.col-resize-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    cursor: col-resize;
}

.ops-data-table tbody td {
    padding: 2px var(--density-cell-px);
    border-bottom: 1px solid var(--table-grid-border);
    vertical-align: middle;
    font-size: 0.74rem;
    color: var(--text-secondary);
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ops-data-table tbody tr:hover {
    background: var(--bg-table-hover);
}

.ops-data-table .col-title {
    min-width: 220px;
    max-width: 320px;
    white-space: normal;
}

.ops-data-table .cell-id a {
    font-weight: 600;
}

.ops-row-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ops-row-actions .btn {
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid var(--border-light);
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-card);
}

.ops-row-actions .btn:hover {
    color: var(--accent);
    border-color: var(--accent-soft);
    background: var(--accent-soft);
}

/* Modal form overflow guard (menu/account forms) */
.modal-form-no-x {
    padding: 12px;
    overflow-x: hidden;
}

.modal-form-no-x .row {
    margin-left: 0;
    margin-right: 0;
}

.modal-form-no-x .row > [class*="col-"] {
    padding-left: 6px;
    padding-right: 6px;
}

.modal-form-no-x .form-control,
.modal-form-no-x .form-select {
    max-width: 100%;
}

.ops-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 20px;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    border: 1px solid transparent;
    line-height: 1.2;
}

.ops-badge.is-danger { color: #b91c1c; background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.18); }
.ops-badge.is-warning { color: #b45309; background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.2); }
.ops-badge.is-success { color: #047857; background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.2); }
.ops-badge.is-info { color: #0369a1; background: rgba(14, 165, 233, 0.11); border-color: rgba(14, 165, 233, 0.2); }
.ops-badge.is-neutral { color: #475569; background: rgba(148, 163, 184, 0.12); border-color: rgba(148, 163, 184, 0.24); }

.ops-code-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 0.7rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
}

.ops-pagination-wrap {
    margin-top: 10px;
    margin-bottom: 15px;
}

.ops-pagination .page-link {
    min-width: 28px;
    text-align: center;
}

.ops-modal-detail .card-header {
    border-radius: 0 !important;
}

.ops-modal-detail .table-bordered th {
    width: 140px;
}

.ops-modal-detail .btn-outline-secondary {
    white-space: nowrap;
}

.ops-kpi-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 8px;
}

.ops-kpi-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--kpi-card-radius);
    box-shadow: var(--kpi-card-shadow);
    padding: 10px 10px 9px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.ops-kpi-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-soft-border);
}

.ops-kpi-card__label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.69rem;
    margin-bottom: 4px;
    white-space: nowrap;
}

.ops-kpi-card__value {
    color: var(--text-heading);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.1;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.dot.is-danger { background: var(--status-danger); }
.dot.is-warning { background: var(--status-warning); }
.dot.is-success { background: var(--status-success); }
.dot.is-info { background: var(--status-info); }
.dot.is-neutral { background: var(--status-neutral); }

.ops-panel-header {
    position: relative;
    z-index: 6;
    min-height: 36px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--table-grid-border);
    background: var(--bg-card);
    border-top-left-radius: var(--panel-radius);
    border-top-right-radius: var(--panel-radius);
}

.ops-panel-header .title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-heading);
}

/* 탭 네비게이션 (콤팩트) */
.nav-tabs-sm .nav-link {
    font-size: 0.78rem;
    padding: 5px 14px;
}
[data-theme="dark"] .nav-tabs-sm .nav-link {
    color: #94a3b8;
}
[data-theme="dark"] .nav-tabs-sm .nav-link.active {
    background: #1e293b;
    border-color: #334155 #334155 #1e293b;
    color: #f1f5f9;
}
[data-theme="dark"] .nav-tabs-sm {
    border-bottom-color: #334155;
}

.ops-priority-list {
    display: grid;
    gap: 3px;
}

.ops-priority-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 4px 8px;
    text-decoration: none;
    background: var(--bg-card);
    color: var(--text-secondary);
}

.ops-priority-item:hover {
    border-color: var(--border-color);
    background: var(--bg-table-hover);
}

.ops-priority-item .label {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.ops-priority-item .value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    border-radius: 999px;
    padding: 0 6px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #fff;
    background: var(--status-neutral);
}

.ops-priority-item .value.is-danger { background: var(--status-danger); }
.ops-priority-item .value.is-warning { background: var(--status-warning); color: #111827; }
.ops-priority-item .value.is-info { background: var(--status-info); }

.ops-data-table--compact thead th {
    padding: 3px 8px;
    font-size: 0.65rem;
}

.ops-data-table--compact tbody td {
    padding: 2px 8px;
    font-size: 0.72rem;
}

[data-theme="dark"] .topbar-search-placeholder,
[data-theme="dark"] .topbar-tools,
[data-theme="dark"] .ops-kpi-card,
[data-theme="dark"] .ops-metric-chip,
[data-theme="dark"] .ops-priority-item,
[data-theme="dark"] .ops-code-pill {
    border-color: #334155;
}

[data-theme="dark"] .ops-badge.is-neutral {
    color: #cbd5e1;
    background: rgba(148, 163, 184, 0.12);
}

[data-theme="dark"] .ops-row-actions .btn {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

[data-theme="dark"] .ops-kpi-card {
    background: #1e293b;
    color: #e2e8f0;
}
[data-theme="dark"] .ops-kpi-card:hover {
    border-color: var(--accent-soft-focus);
}
[data-theme="dark"] .ops-kpi-card__value {
    color: #f1f5f9;
}
[data-theme="dark"] .ops-metric-chip {
    background: #1e293b;
    color: #cbd5e1;
}
[data-theme="dark"] .ops-metric-chip strong {
    color: #f1f5f9;
}
[data-theme="dark"] .ops-metric-chip.is-danger { border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.08); }
[data-theme="dark"] .ops-metric-chip.is-warning { border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.08); }
[data-theme="dark"] .ops-metric-chip.is-success { border-color: rgba(16, 185, 129, 0.3); background: rgba(16, 185, 129, 0.08); }
[data-theme="dark"] .ops-metric-chip.is-info { border-color: rgba(14, 165, 233, 0.3); background: rgba(14, 165, 233, 0.08); }
[data-theme="dark"] .ops-metric-chip.is-neutral { border-color: rgba(100, 116, 139, 0.3); background: rgba(100, 116, 139, 0.08); }

[data-theme="dark"] .ops-priority-item {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}
[data-theme="dark"] .ops-priority-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: #475569;
}
[data-theme="dark"] .ops-priority-item .label {
    color: #cbd5e1;
}

[data-theme="dark"] .ops-panel-header {
    background: #1e293b;
    border-color: #334155;
}
[data-theme="dark"] .ops-panel-header .title {
    color: #f1f5f9;
}

[data-theme="dark"] .ops-filter-card .card-body {
    background: #1e293b;
}
[data-theme="dark"] .ops-date-chip {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}
[data-theme="dark"] .ops-code-pill {
    background: #0f172a;
    color: #94a3b8;
}

/* --- Bootstrap table contextual classes (risk matrix etc.) --- */
[data-theme="dark"] .table-danger,
[data-theme="dark"] .table-danger > td,
[data-theme="dark"] .table-danger > th {
    background-color: rgba(239, 68, 68, 0.12) !important;
    color: #fca5a5;
}
[data-theme="dark"] .table-warning,
[data-theme="dark"] .table-warning > td,
[data-theme="dark"] .table-warning > th {
    background-color: rgba(245, 158, 11, 0.12) !important;
    color: #fcd34d;
}
[data-theme="dark"] .table-success,
[data-theme="dark"] .table-success > td,
[data-theme="dark"] .table-success > th {
    background-color: rgba(16, 185, 129, 0.12) !important;
    color: #6ee7b7;
}
[data-theme="dark"] .table-info,
[data-theme="dark"] .table-info > td,
[data-theme="dark"] .table-info > th {
    background-color: rgba(14, 165, 233, 0.12) !important;
    color: #7dd3fc;
}
[data-theme="dark"] .table-primary,
[data-theme="dark"] .table-primary > td,
[data-theme="dark"] .table-primary > th {
    background-color: rgba(139, 92, 246, 0.12) !important;
    color: #c4b5fd;
}
[data-theme="dark"] .table-secondary,
[data-theme="dark"] .table-secondary > td,
[data-theme="dark"] .table-secondary > th {
    background-color: rgba(100, 116, 139, 0.12) !important;
    color: #cbd5e1;
}
[data-theme="dark"] .table-light,
[data-theme="dark"] .table-light > td,
[data-theme="dark"] .table-light > th {
    background-color: rgba(255, 255, 255, 0.04) !important;
    color: #cbd5e1;
}
[data-theme="dark"] .table-dark,
[data-theme="dark"] .table-dark > td,
[data-theme="dark"] .table-dark > th {
    background-color: #0f172a !important;
    color: #e2e8f0;
}

/* --- Badge bg-dark in dark mode --- */
[data-theme="dark"] .badge.bg-dark {
    background: #475569 !important;
    color: #f1f5f9 !important;
}

/* --- fw-bold text color in dark --- */
[data-theme="dark"] .fw-bold,
[data-theme="dark"] .fw-semibold {
    color: inherit;
}

/* --- card-header strong/h6 in dark --- */
[data-theme="dark"] .card-header strong,
[data-theme="dark"] .card-header {
    color: #f1f5f9;
}

/* --- btn-outline-primary dark --- */
[data-theme="dark"] .btn-outline-primary {
    color: #a78bfa;
    border-color: #a78bfa;
}
[data-theme="dark"] .btn-outline-primary:hover {
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
    border-color: #c4b5fd;
}
[data-theme="dark"] .btn-outline-success {
    color: #6ee7b7;
    border-color: #6ee7b7;
}
[data-theme="dark"] .btn-outline-success:hover {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border-color: #6ee7b7;
}
[data-theme="dark"] .btn-outline-warning {
    color: #fcd34d;
    border-color: #fcd34d;
}
[data-theme="dark"] .btn-outline-warning:hover {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border-color: #fcd34d;
}
[data-theme="dark"] .btn-outline-info {
    color: #7dd3fc;
    border-color: #7dd3fc;
}
[data-theme="dark"] .btn-outline-info:hover {
    background: rgba(14, 165, 233, 0.15);
    color: #7dd3fc;
    border-color: #7dd3fc;
}

@media (max-width: 1600px) {
    .ops-kpi-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .ops-filter-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .ops-field--search {
        grid-column: span 2;
    }
}

@media (max-width: 1200px) {
    .topbar-search-slot {
        display: none !important;
    }
    .ops-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .ops-table-shell { max-height: clamp(300px, calc(100vh - 240px), 70vh); }
}

@media (max-width: 992px) {
    .ops-page-header {
        flex-direction: column;
        align-items: stretch;
    }
    .ops-table-shell { max-height: clamp(280px, calc(100vh - 210px), 68vh); }
    .ops-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .ops-field--search {
        grid-column: 1 / -1;
    }
    .ops-filter-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 576px) {
    .ops-kpi-grid {
        grid-template-columns: 1fr;
    }
    .ops-filter-grid {
        grid-template-columns: 1fr;
    }
    .ops-table-shell {
        max-height: 62vh;
        overflow-x: auto;
    }
    .user-info {
        display: none;
    }
}

/* ══════════════════════════════════════
   AG Grid Wz-QMS 테마 오버라이드
   항상 ag-theme-balham 클래스만 사용.
   다크 모드는 [data-theme="dark"]로 특이성 확보하여 강제 오버라이드.
   ══════════════════════════════════════ */
.ag-theme-balham {
    --ag-font-family: 'Pretendard Variable', sans-serif;
    --ag-font-size: 11.5px;
    --ag-row-height: 26px;
    --ag-header-height: 28px;
    --ag-header-foreground-color: var(--text-primary);
    --ag-foreground-color: var(--text-primary);
    --ag-data-color: var(--text-primary);
    --ag-border-color: var(--border-color);
    --ag-row-border-color: var(--border-color);
    --ag-secondary-border-color: var(--border-color);
    --ag-row-hover-color: var(--bg-table-hover);
    --ag-selected-row-background-color: var(--bg-table-hover);
    --ag-range-selection-background-color: transparent;
    --ag-header-background-color: var(--bg-table-header);
    --ag-odd-row-background-color: rgba(0, 0, 0, 0.015);
    --ag-background-color: var(--bg-card);
    --ag-data-background-color: var(--bg-card);
    --ag-control-panel-background-color: var(--bg-card);
    --ag-subheader-background-color: var(--bg-card);
    --ag-input-focus-border-color: var(--accent);
    --ag-checkbox-checked-color: var(--accent);
    --ag-input-border-color: var(--border-color);
    width: 100%;
}

/* 다크 모드: [data-theme="dark"]로 특이성을 높여 CDN 기본값을 확실히 덮어씀 */
[data-theme="dark"] .ag-theme-balham {
    --ag-background-color: #1e293b;
    --ag-data-background-color: #1e293b;
    --ag-foreground-color: #e2e8f0;
    --ag-data-color: #e2e8f0;
    --ag-header-foreground-color: #e2e8f0;
    --ag-header-background-color: #1e293b;
    --ag-border-color: #334155;
    --ag-row-border-color: #334155;
    --ag-secondary-border-color: #334155;
    --ag-row-hover-color: rgba(255, 255, 255, 0.05);
    --ag-selected-row-background-color: rgba(139, 92, 246, 0.12);
    --ag-odd-row-background-color: rgba(255, 255, 255, 0.02);
    --ag-control-panel-background-color: #1e293b;
    --ag-subheader-background-color: #1e293b;
    --ag-input-border-color: #334155;
    --ag-input-focus-border-color: #8b5cf6;
    --ag-checkbox-checked-color: #8b5cf6;
    --ag-modal-overlay-background-color: rgba(15, 23, 42, 0.66);
    --ag-column-hover-color: rgba(255, 255, 255, 0.03);
    --ag-range-selection-background-color: rgba(139, 92, 246, 0.15);
    --ag-chip-background-color: #334155;
    --ag-invalid-color: #ef4444;
    --ag-icon-font-color: #94a3b8;
}

/* 다크 모드: AG Grid 내부 요소 직접 오버라이드 (!important로 CDN 스타일 완전 덮어씀) */
[data-theme="dark"] .ag-theme-balham .ag-root-wrapper {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
}
[data-theme="dark"] .ag-theme-balham .ag-header {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-bottom-color: #334155 !important;
}
[data-theme="dark"] .ag-theme-balham .ag-header-row {
    background-color: #1e293b !important;
}
[data-theme="dark"] .ag-theme-balham .ag-header-cell {
    color: #e2e8f0 !important;
}
[data-theme="dark"] .ag-theme-balham .ag-row {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-bottom-color: #334155 !important;
}
[data-theme="dark"] .ag-theme-balham .ag-row-odd {
    background-color: #1a2637 !important;
}
[data-theme="dark"] .ag-theme-balham .ag-row-hover,
[data-theme="dark"] .ag-theme-balham .ag-row.ag-row-hover {
    background-color: #253348 !important;
}
[data-theme="dark"] .ag-theme-balham .ag-row-selected {
    background-color: rgba(139, 92, 246, 0.18) !important;
}
[data-theme="dark"] .ag-theme-balham .ag-cell {
    color: #e2e8f0 !important;
}
[data-theme="dark"] .ag-theme-balham .ag-body-viewport,
[data-theme="dark"] .ag-theme-balham .ag-center-cols-viewport,
[data-theme="dark"] .ag-theme-balham .ag-center-cols-container,
[data-theme="dark"] .ag-theme-balham .ag-body {
    background-color: #1e293b !important;
}
[data-theme="dark"] .ag-theme-balham .ag-paging-panel {
    background-color: #1e293b !important;
    color: #cbd5e1 !important;
    border-top-color: #334155 !important;
}
[data-theme="dark"] .ag-theme-balham .ag-icon {
    color: #94a3b8 !important;
}
[data-theme="dark"] .ag-theme-balham .ag-header-cell-resize::after {
    background-color: #334155 !important;
}
[data-theme="dark"] .ag-theme-balham .ag-paging-button {
    color: #cbd5e1 !important;
}
[data-theme="dark"] .ag-theme-balham .ag-disabled .ag-paging-button {
    color: #475569 !important;
}
[data-theme="dark"] .ag-theme-balham input.ag-input-field-input {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
[data-theme="dark"] .ag-theme-balham .ag-filter,
[data-theme="dark"] .ag-theme-balham .ag-popup-child {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
[data-theme="dark"] .ag-theme-balham .ag-sort-ascending-icon,
[data-theme="dark"] .ag-theme-balham .ag-sort-descending-icon,
[data-theme="dark"] .ag-theme-balham .ag-sort-none-icon,
[data-theme="dark"] .ag-theme-balham .ag-header-icon {
    color: #94a3b8 !important;
}
[data-theme="dark"] .ag-theme-balham a {
    color: #a78bfa !important;
}
/* 다크 모드: 텍스트 드래그 선택 영역 가시성 강화 */
[data-theme="dark"] .ag-theme-balham .ag-cell ::selection,
[data-theme="dark"] .ag-theme-balham .ag-cell::selection {
    background: rgba(96, 165, 250, 0.45) !important;
    color: #fff !important;
}
/* 다크 모드: 선택된 행 + 호버 조합 */
[data-theme="dark"] .ag-theme-balham .ag-row-selected.ag-row-hover {
    background-color: rgba(139, 92, 246, 0.22) !important;
}
/* 다크 모드: 셀 포커스 테두리 */
[data-theme="dark"] .ag-theme-balham .ag-cell-focus:not(.ag-cell-range-selected) {
    border-color: rgba(139, 92, 246, 0.6) !important;
}

/* 결과 입력 그리드 — 셀 배경 (라이트/다크 공용) */
.ag-theme-balham .cell-result-input {
    background-color: rgba(34, 139, 34, 0.04) !important;
}
.ag-theme-balham .cell-result-disabled {
    background-color: #f5f5f5 !important;
}
.ag-theme-balham .cell-result-auto {
    background-color: rgba(30, 100, 200, 0.04) !important;
}
[data-theme="dark"] .ag-theme-balham .cell-result-input {
    background-color: rgba(120, 220, 120, 0.08) !important;
}
[data-theme="dark"] .ag-theme-balham .cell-result-disabled {
    background-color: rgba(255, 255, 255, 0.03) !important;
}
[data-theme="dark"] .ag-theme-balham .cell-result-auto {
    background-color: rgba(100, 160, 255, 0.08) !important;
}

.ag-theme-balham .ag-header-cell-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ag-theme-balham .ag-cell {
    display: flex;
    align-items: center;
    line-height: 1.3;
    padding-left: 6px;
    padding-right: 6px;
    font-size: 12px;
}

/* 숫자 컬럼 우측 정렬 (ag-grid-common.js cellClass에서 자동 적용) */
.ag-theme-balham .ag-right-aligned-cell {
    justify-content: flex-end;
    text-align: right !important;
}
.ag-theme-balham .ag-right-aligned-header .ag-header-cell-label {
    justify-content: flex-end;
}

.ag-theme-balham .ag-header-cell {
    padding-left: 6px;
    padding-right: 6px;
}

.ag-theme-balham .ag-cell .ops-badge,
.ag-theme-balham .ag-cell .ops-row-actions {
    display: inline-flex;
    align-items: center;
}

.ag-theme-balham .ag-paging-panel {
    font-size: 0.7rem;
    height: 30px;
    border-top: 1px solid var(--border-color);
}

/* ── QMS Set Filter (Community 대체) ── */
.qms-set-filter {
    width: 220px;
    max-height: 320px;
    display: flex;
    flex-direction: column;
    font-size: 12px;
    padding: 6px;
    background: var(--bg-card);
    color: var(--text-default);
}
.qms-sf-search {
    flex-shrink: 0;
    margin-bottom: 4px;
}
.qms-sf-input {
    width: 100%;
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--bg-input);
    color: var(--text-default);
    outline: none;
}
.qms-sf-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}
.qms-sf-list {
    flex: 1 1 auto;
    overflow-y: auto;
    max-height: 260px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--bg-input);
}
.qms-sf-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
}
.qms-sf-item:hover {
    background: var(--accent-soft);
}
.qms-sf-item input[type="checkbox"] {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}
.qms-sf-item span {
    overflow: hidden;
    text-overflow: ellipsis;
}
.qms-sf-selectall {
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    padding: 4px 8px;
}
/* 다크 모드: Set Filter */
[data-theme="dark"] .qms-set-filter {
    background: #1e293b;
    color: #e2e8f0;
}
[data-theme="dark"] .qms-sf-input {
    background: #0f172a;
    color: #e2e8f0;
    border-color: #334155;
}
[data-theme="dark"] .qms-sf-input:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}
[data-theme="dark"] .qms-sf-list {
    background: #0f172a;
    border-color: #334155;
}
[data-theme="dark"] .qms-sf-item:hover {
    background: rgba(99, 102, 241, 0.15);
}
[data-theme="dark"] .qms-sf-selectall {
    border-bottom-color: #334155;
}

/* ── AG Grid 목록 페이지: 한 화면 레이아웃 (페이지 스크롤 없음) ── */
.content-area--grid-list > .content-scroll {
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    padding-bottom: 0;
}
.content-area--grid-list > .content-scroll > * {
    flex-shrink: 0;
}
.content-area--grid-list > .content-scroll > .card.ops-panel:last-of-type {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.content-area--grid-list .card.ops-panel > .ag-grid-toolbar {
    flex-shrink: 0;
}
.content-area--grid-list .card.ops-panel > [class*="ag-theme-"] {
    flex: 1 1 auto;
    min-height: 0;
}

.ag-grid-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
    font-size: 0.75rem;
}

.ag-grid-toolbar .ops-table-toolbar__count {
    font-size: 0.75rem;
}

.ag-grid-toolbar .btn {
    font-size: 0.72rem;
    padding: 2px 8px;
}

/* ══════════════════════════════════════
   날짜 입력(input[type="date"]) 테마 대응
   ══════════════════════════════════════ */
input[type="date"] {
    color-scheme: light;
}
[data-theme="dark"] input[type="date"] {
    color-scheme: dark;
    background-color: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-color);
}
[data-theme="dark"] input[type="date"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(var(--accent-rgb), 0.25);
}

/* ══════════════════════════════════════
   워크플로우 스텝 인디케이터
   ══════════════════════════════════════ */
.wf-steps {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 10px 16px;
    overflow-x: auto;
}

.wf-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.wf-step__dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-card, #fff);
    position: relative;
    transition: all 0.2s;
}

.wf-step__label {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 500;
}

.wf-step__connector {
    width: 28px;
    height: 2px;
    background: var(--border-color);
    flex-shrink: 0;
    margin-bottom: 18px;
}

/* 완료 상태 */
.wf-step--done .wf-step__dot {
    background: var(--accent);
    border-color: var(--accent);
}
.wf-step--done .wf-step__dot::after {
    content: '';
    position: absolute;
    top: 3px; left: 5px;
    width: 5px; height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.wf-step--done .wf-step__label {
    color: var(--accent);
}
.wf-step__connector--done {
    background: var(--accent);
}

/* 현재 상태 */
.wf-step--current .wf-step__dot {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.2);
    animation: wf-pulse 2s ease-in-out infinite;
}
.wf-step--current .wf-step__dot::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 6px; height: 6px;
    background: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}
.wf-step--current .wf-step__label {
    color: var(--text-primary);
    font-weight: 700;
}

/* 대기 상태 */
.wf-step--pending .wf-step__dot {
    background: transparent;
    border-color: var(--border-color);
}
.wf-step--pending .wf-step__label {
    color: var(--text-muted);
}

@keyframes wf-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.2); }
    50% { box-shadow: 0 0 0 8px rgba(var(--accent-rgb), 0.1); }
}

/* Mermaid 다이어그램 컨테이너 */
.wf-diagram-container {
    padding: 12px;
    text-align: center;
    overflow-x: auto;
}
.wf-diagram-container svg {
    max-width: 100%;
    height: auto;
}

/* 현재 상태 하이라이트 (Mermaid SVG 내부) */
.wf-current-state rect {
    stroke: var(--accent) !important;
    stroke-width: 3px !important;
    filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), 0.5)) !important;
}

/* 워크플로우 패널 (상세 페이지 내) */
.wf-panel {
    border: 1px solid var(--border-color);
    border-radius: var(--panel-radius, 8px);
    background: var(--bg-card);
    margin-bottom: 12px;
}
.wf-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
}
.wf-panel__header:hover {
    background: var(--bg-table-hover);
}
.wf-panel__title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.wf-panel__toggle {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}
.wf-panel.collapsed .wf-panel__toggle {
    transform: rotate(-90deg);
}
.wf-panel.collapsed .wf-panel__body {
    display: none;
}

/* ===== AI 채팅 위젯 ===== */
#aiChatWidget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1050;
    font-size: 13px;
}

/* 토글 버튼 */
.btn-ai-toggle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
}
.btn-ai-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.ai-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 채팅 패널 */
.ai-chat-panel {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 380px;
    height: 560px;
    min-width: 280px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
    overflow: visible; /* 리사이즈 핸들을 위해 visible */
}
.ai-chat-header { user-select: none; }
.ai-msg-body { user-select: text; cursor: text; }
.ai-chat-panel.minimized {
    height: auto !important;
    min-height: 0;
    resize: none;
}

/* 패널 본문 래퍼 */
.ai-chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 0 0 16px 16px;
}
.ai-chat-panel.minimized .ai-chat-body {
    display: none;
}

/* 리사이즈 핸들 */
.ai-resize-handle {
    position: absolute;
    z-index: 20;
}
.ai-resize-n {
    top: -4px; left: 16px; right: 16px;
    height: 8px;
    cursor: n-resize;
}
.ai-resize-w {
    left: -4px; top: 16px; bottom: 16px;
    width: 8px;
    cursor: w-resize;
}
.ai-resize-nw {
    top: -4px; left: -4px;
    width: 16px; height: 16px;
    cursor: nw-resize;
}
.ai-resize-handle:hover::after {
    content: '';
    position: absolute;
    inset: 2px;
    background: var(--accent);
    opacity: 0.25;
    border-radius: 3px;
}

/* 헤더 */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--accent);
    color: #fff;
    flex-shrink: 0;
    cursor: move;
    border-radius: 16px 16px 0 0;
}
.ai-chat-panel.minimized .ai-chat-header {
    border-radius: 16px;
}
.ai-chat-title {
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
}
.ai-chat-actions {
    display: flex;
    gap: 4px;
}
.btn-ai-icon {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: background 0.15s;
    padding: 0;
}
.btn-ai-icon:hover {
    background: rgba(255,255,255,0.3);
}

/* 세션 목록 패널 */
.ai-sessions-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-card);
    z-index: 10;
    display: flex;
    flex-direction: column;
    border-radius: 0 0 16px 16px;
    overflow: hidden;
}
.ai-sessions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    font-weight: 600;
    font-size: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    flex-shrink: 0;
}
.ai-sessions-list {
    flex: 1;
    overflow-y: auto;
}
.ai-session-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.1s;
}
.ai-session-item:hover {
    background: var(--bg-table-hover);
}
.ai-session-item.active {
    background: var(--accent-soft);
}
.ai-session-title {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ai-session-meta {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}
.btn-ai-session-del {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.15s;
}
.ai-session-item:hover .btn-ai-session-del {
    opacity: 1;
}
.btn-ai-session-del:hover {
    color: #ef4444;
}
.ai-sessions-empty {
    text-align: center;
    color: var(--text-muted);
}

/* 메시지 영역 */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 웰컴 메시지 */
.ai-welcome-msg {
    text-align: center;
    padding: 20px 12px;
    color: var(--text-secondary);
}
.ai-welcome-icon {
    font-size: 36px;
    color: var(--accent);
}
.ai-quick-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 10px;
}
.btn-ai-quick {
    background: var(--accent-soft);
    border: 1px solid var(--accent-soft-border);
    color: var(--accent);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-ai-quick:hover {
    background: var(--accent-soft-hover);
}
.ai-welcome-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #059669;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 6px;
}
[data-theme="dark"] .ai-welcome-badge {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.35);
    color: #34d399;
}

/* 메시지 버블 */
.ai-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.ai-msg-user {
    flex-direction: row-reverse;
}
.ai-msg-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    padding: 4px;
}
.ai-msg-user .ai-msg-icon {
    background: var(--bg-table-header);
    color: var(--text-secondary);
}
.ai-msg-content {
    max-width: 82%;
}
.ai-msg-body {
    background: var(--bg-table-header);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-primary);
    word-break: break-word;
}
.ai-msg-assistant .ai-msg-body {
    background: var(--bg-table-header);
}
.ai-msg-user .ai-msg-body {
    background: var(--accent);
    color: #fff;
}

/* 마크다운 스타일 */
.ai-msg-body .ai-code-block {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    font-size: 11px;
    overflow-x: auto;
    margin: 4px 0;
    white-space: pre;
}
.ai-msg-body .ai-inline-code {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 11px;
    font-family: monospace;
}
.ai-msg-body .ai-h4, .ai-msg-body .ai-h5, .ai-msg-body .ai-h6 {
    font-weight: 700;
    margin: 6px 0 2px;
}
.ai-msg-body .ai-h4 { font-size: 14px; }
.ai-msg-body .ai-h5 { font-size: 13px; }
.ai-msg-body .ai-h6 { font-size: 12px; }
.ai-msg-body ul, .ai-msg-body ol {
    padding-left: 18px;
    margin: 4px 0;
}
.ai-msg-body li { margin: 2px 0; }
.ai-msg-body .ai-hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 8px 0;
}

/* 타이핑 스피너 */
.ai-typing-spinner {
    display: flex;
    gap: 4px;
    padding: 10px;
    align-items: center;
}
.ai-typing-spinner span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: aiDotBounce 1.2s infinite ease-in-out;
}
.ai-typing-spinner span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-spinner span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiDotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* 툴 알림 */
.ai-tool-notice {
    background: var(--bs-success-bg-subtle, #d1fae5);
    border: 1px solid var(--bs-success-border-subtle, #6ee7b7);
    color: var(--bs-success-text-emphasis, #065f46);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 11.5px;
}
[data-theme="dark"] .ai-tool-notice {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

/* 에러 */
.ai-error-msg {
    background: var(--bs-danger-bg-subtle, #fee2e2);
    border: 1px solid var(--bs-danger-border-subtle, #fca5a5);
    color: var(--bs-danger-text-emphasis, #991b1b);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 11.5px;
}
[data-theme="dark"] .ai-error-msg {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

/* 입력 영역 */
.ai-chat-footer {
    border-top: 1px solid var(--border-color);
    padding: 8px 10px;
    flex-shrink: 0;
    background: var(--bg-card);
}
.ai-chat-input-wrap {
    display: flex;
    gap: 6px;
    align-items: flex-end;
}
.ai-chat-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 7px 10px;
    font-size: 12.5px;
    background: var(--bg-input);
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
    line-height: 1.5;
    max-height: 120px;
    overflow-y: auto;
}
.ai-chat-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft-focus);
}
.btn-ai-send {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    transition: background 0.15s, opacity 0.15s;
}
.btn-ai-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.btn-ai-send:not(:disabled):hover {
    background: var(--accent-light);
}
.ai-chat-hint {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* AI 위젯 숨김 */
#aiChatWidget.ai-widget-hidden { display: none !important; }
/* Topbar AI 버튼 활성 */
#topbarAiBtn.active { color: var(--accent) !important; background: var(--accent-soft) !important; }

/* 로컬 조회 배지 */
.ai-local-badge {
    display: inline-flex;
    align-items: center;
    margin-top: 4px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #059669;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
}
[data-theme="dark"] .ai-local-badge {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.35);
    color: #34d399;
}

/* 다크모드 오버라이드 */
[data-theme="dark"] .ai-chat-panel {
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
[data-theme="dark"] .ai-msg-user .ai-msg-body {
    color: #fff;
}



/* ============================================================
   인쇄 전용 (@media print) - GMP 인쇄 품질 + 다크 테마 무력화
   ============================================================ */
@media print {
    /* 다크 테마 변수 무력화 — 인쇄는 항상 흰 배경 */
    :root,
    [data-theme],
    [data-theme="dark"],
    [data-theme="indigo"],
    [data-theme="ocean"],
    [data-theme="forest"],
    [data-theme="rose"] {
        --bg-body: white !important;
        --topbar-bg: white !important;
        --sidebar-bg: white !important;
        --text-primary: black !important;
        --text-secondary: #333 !important;
    }

    .sidebar,
    .topbar,
    .ai-chat-widget,
    .ai-chat-panel,
    .modal,
    .modal-backdrop,
    .ops-page-header__actions,
    .ops-filter-card,
    .ops-summary-strip,
    .ag-grid-toolbar,
    .ag-paging-panel,
    .ag-side-bar,
    .work-tabs-bar,
    .messages-container,
    [data-no-print],
    .btn,
    button {
        display: none !important;
    }

    html,
    html[data-theme],
    html[data-theme="dark"],
    body,
    body[data-theme],
    body[data-theme="dark"] {
        background: white !important;
        background-color: white !important;
        color: black !important;
    }

    .main-content,
    .content-area,
    .content-scroll {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
        overflow: visible !important;
        background: white !important;
        color: black !important;
    }

    /* 배경색 인쇄 강제 (브라우저 기본은 백그라운드 미인쇄) */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    .card,
    .ops-panel {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        background: white !important;
        page-break-inside: avoid;
    }
    .card-header {
        background: #f5f5f5 !important;
        color: black !important;
        border-bottom: 1px solid #ccc !important;
    }

    table,
    .table {
        background: white !important;
        color: black !important;
        border-collapse: collapse !important;
    }
    table th,
    table td,
    .table th,
    .table td {
        border: 1px solid #ccc !important;
        background: white !important;
        color: black !important;
    }
    table thead,
    .table thead {
        background: #f5f5f5 !important;
    }

    a,
    a:visited {
        color: black !important;
        text-decoration: none !important;
    }

    /* AG Grid — 다크 테마 셀렉터(0,2,0) 무력화 위해 동일/높은 specificity 사용 */
    .ag-theme-balham,
    [data-theme] .ag-theme-balham,
    [data-theme="dark"] .ag-theme-balham,
    [data-theme="ocean"] .ag-theme-balham,
    [data-theme="forest"] .ag-theme-balham,
    [data-theme="rose"] .ag-theme-balham,
    [data-theme="indigo"] .ag-theme-balham {
        --ag-background-color: white !important;
        --ag-foreground-color: black !important;
        --ag-header-background-color: #f5f5f5 !important;
        --ag-header-foreground-color: black !important;
        --ag-odd-row-background-color: white !important;
        --ag-even-row-background-color: white !important;
        --ag-row-hover-color: white !important;
        --ag-border-color: #ccc !important;
        --ag-secondary-border-color: #ccc !important;
        --ag-control-panel-background-color: white !important;
        background: white !important;
    }
    [data-theme] .ag-theme-balham .ag-root-wrapper,
    [data-theme] .ag-theme-balham .ag-root,
    [data-theme] .ag-theme-balham .ag-body,
    [data-theme] .ag-theme-balham .ag-body-viewport,
    [data-theme] .ag-theme-balham .ag-center-cols-clipper,
    [data-theme] .ag-theme-balham .ag-center-cols-container,
    [data-theme] .ag-theme-balham .ag-cell,
    [data-theme] .ag-theme-balham .ag-row,
    [data-theme] .ag-theme-balham .ag-row-even,
    [data-theme] .ag-theme-balham .ag-row-odd,
    [data-theme] .ag-theme-balham .ag-row-hover,
    [data-theme] .ag-theme-balham .ag-row-selected,
    [data-theme] .ag-theme-balham .ag-pinned-left-cols-container,
    [data-theme] .ag-theme-balham .ag-pinned-right-cols-container,
    [data-theme] .ag-theme-balham .ag-floating-bottom,
    [data-theme] .ag-theme-balham .ag-floating-top,
    [data-theme] .ag-theme-balham .ag-overlay,
    [data-theme] .ag-theme-balham .ag-overlay-no-rows-wrapper,
    [data-theme] .ag-theme-balham .ag-paging-panel,
    [data-theme] .ag-theme-balham .ag-status-bar {
        background-color: white !important;
        color: black !important;
        background: white !important;
    }
    [data-theme] .ag-theme-balham .ag-header,
    [data-theme] .ag-theme-balham .ag-header-row,
    [data-theme] .ag-theme-balham .ag-header-cell {
        background-color: #f5f5f5 !important;
        color: black !important;
    }

    /* 최후의 수단: AG Grid 안의 모든 요소 흰색 강제 (헤더/배지 제외) */
    [data-theme] .ag-theme-balham *:not(.ag-header):not(.ag-header-row):not(.ag-header-cell):not(.ag-header-cell-text):not(.ag-header-cell-label):not(.ag-header-cell-comp-wrapper):not(.ops-badge):not(.badge) {
        background-color: white !important;
        background: white !important;
        background-image: none !important;
        color: black !important;
    }
    [data-theme] .ag-theme-balham {
        background-color: white !important;
        background: white !important;
    }

    .ops-badge,
    .badge {
        background: #eee !important;
        color: black !important;
        border: 1px solid #ccc !important;
        padding: 2px 6px !important;
    }

    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
    p, li, blockquote {
        page-break-inside: avoid;
    }

    /* 페이지 컨테이너만 흰색 강제 (badge/panel 등은 보존) */
    html,
    body,
    body[data-theme],
    body[data-theme="dark"],
    body > .d-flex,
    .main-content,
    .content-area,
    .content-scroll {
        background-color: white !important;
        background-image: none !important;
        background: white !important;
    }

    @page {
        margin: 12mm 10mm;
        background: white;
    }
}

/* ── 그리드 컬럼 설정 모달 ── */
.qms-colset-list { display: flex; flex-direction: column; gap: 4px; }
.qms-colset-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border: 1px solid var(--border-color, #dee2e6);
    border-radius: 6px; background: var(--card-bg, #fff);
}
.qms-colset-row.dragging { opacity: .5; border-style: dashed; border-color: var(--accent, #6366f1); background: rgba(99, 102, 241, .06); }
.qms-colset-handle { cursor: grab; color: #888; font-size: 16px; user-select: none; }
.qms-colset-show { margin: 0; }
.qms-colset-name { flex: 1 1 auto; font-size: 13px; }
.qms-colset-width { width: 80px; font-size: 12px; padding: 2px 6px; }
[data-theme="dark"] .qms-colset-row { background: #2a2d34; border-color: #3a3f48; }
