/* 全局設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dark 主題色彩 */
    --bg-primary: #0a0e27;
    --bg-secondary: #151932;
    --bg-card: #1a1f3a;
    --accent-cyan: #00d9ff;
    --accent-blue: #0066ff;
    --accent-purple: #6366f1;
    --risk-critical: #ef4444;
    --risk-high: #f97316;
    --risk-medium: #eab308;
    --risk-low: #22c55e;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #2d3548;
    --glow-cyan: 0 0 20px rgba(0, 217, 255, 0.3);
    --glow-blue: 0 0 20px rgba(0, 102, 255, 0.3);
}

/* Light 主題色彩 */
body.light-theme {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

body:not(.light-theme) {
    background-image:
        radial-gradient(circle at 20% 50%, rgba(0, 217, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.05) 0%, transparent 50%);
}

/* 頂部工具列 - 左藍右黑漸層 */
.header {
    background: linear-gradient(90deg, rgba(0, 102, 255, 0.3) 0%, rgba(10, 14, 39, 0.95) 50%, rgba(0, 0, 0, 0.98) 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

body.light-theme .header {
    background: linear-gradient(90deg, rgba(0, 102, 255, 0.1) 0%, rgba(255, 255, 255, 0.95) 50%, rgba(248, 250, 252, 1) 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-left: 2rem;  /* 與專案選單保持間距 */
}

.logo-text {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
    font-family: 'Courier New', monospace;
    filter: drop-shadow(0 0 20px rgba(0, 217, 255, 0.5));
}

/* 專案選擇器包裝 */
.project-selector-wrapper {
    position: relative;
    margin-left: -1rem;  /* 縮小與公司選單之間的間距 */
}

/* 公司下拉選單 */
.company-selector-wrapper {
    position: relative;
}

.company-dropdown {
    position: relative;
}

.company-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--accent-purple);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
}

.company-dropdown-btn:hover {
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.4);
}

.company-dropdown-btn .company-icon {
    font-size: 1rem;
}

.company-dropdown-btn .company-name {
    flex: 1;
    text-align: left;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.company-dropdown-btn .company-arrow {
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.company-dropdown.open .company-arrow {
    transform: rotate(180deg);
}

.company-dropdown-menu {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    min-width: 180px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    overflow: hidden;
}

.company-dropdown.open .company-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 下拉選單載入中狀態 */
.dropdown-loading {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.company-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.company-option:last-child {
    border-bottom: none;
}

.company-option:hover {
    background: var(--bg-secondary);
}

.company-option.active {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(99, 102, 241, 0.15));
    border-left: 3px solid var(--accent-purple);
}

.company-option-icon {
    font-size: 1rem;
}

.company-option-name {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

body.light-theme .company-dropdown-menu {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

body.light-theme .company-dropdown-btn {
    background: #ffffff;
}

/* 專案下拉選單 */
.project-dropdown {
    position: relative;
}

.project-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--accent-cyan);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.project-dropdown-btn:hover {
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.4);
}

.project-dropdown-btn .project-name {
    flex: 1;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.project-dropdown-btn .project-arrow {
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.project-dropdown.open .project-arrow {
    transform: rotate(180deg);
}

.project-dropdown-menu {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    min-width: 240px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    overflow: hidden;
}

.project-dropdown.open .project-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.project-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.project-option:last-child {
    border-bottom: none;
}

.project-option:hover {
    background: var(--bg-secondary);
}

.project-option.active {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.15), rgba(99, 102, 241, 0.15));
    border-left: 3px solid var(--accent-cyan);
}

.project-option-name {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.project-option-icon {
    font-size: 1rem;
    margin-right: 0.3rem;
}

/* 專案選項分隔線 */
.project-option-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.3rem 0;
}

/* 新建專案選項 */
.project-option-create {
    color: var(--accent-purple);
    display: flex;
    align-items: center;
}

.project-option-create:hover {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(99, 102, 241, 0.15));
}

.project-option-create .project-option-name {
    color: var(--accent-purple);
}

/* 專案運行模式標籤 */
.project-mode-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.project-mode-tag[data-mode="bypass"] {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
    border: 1px solid #6b7280;
}

.project-mode-tag[data-mode="monitor"] {
    background: rgba(0, 217, 255, 0.2);
    color: var(--accent-cyan);
    border: 1px solid var(--accent-cyan);
}

.project-mode-tag[data-mode="enforce"] {
    background: rgba(239, 68, 68, 0.2);
    color: var(--risk-critical);
    border: 1px solid var(--risk-critical);
}

.project-mode-tag[data-mode="all"] {
    display: none;
}

body.light-theme .project-dropdown-menu {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

body.light-theme .project-dropdown-btn {
    background: #ffffff;
}

/* 語言下拉選單 - 已移至帳號設定 */
.language-dropdown {
    display: none; /* 隱藏，已移至帳號設定彈窗 */
    position: relative;
}

.lang-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
}

.lang-dropdown-btn:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.2);
}

.lang-dropdown-btn .lang-flag {
    font-size: 1.1rem;
}

.lang-dropdown-btn .lang-name {
    font-size: 0.85rem;
    font-weight: 500;
    flex: 1;
    text-align: left;
}

.lang-dropdown-btn .lang-arrow {
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.language-dropdown.open .lang-arrow {
    transform: rotate(180deg);
}

.lang-dropdown-menu {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    min-width: 160px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    overflow: hidden;
}

.language-dropdown.open .lang-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.lang-option:last-child {
    border-bottom: none;
}

.lang-option:hover {
    background: var(--bg-secondary);
}

.lang-option.active {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.15), rgba(99, 102, 241, 0.15));
    border-left: 3px solid var(--accent-cyan);
}

.lang-option .lang-flag {
    font-size: 1.2rem;
}

.lang-option .lang-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
}

body.light-theme .lang-dropdown-menu {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

/* 主題切換按鈕 - 已移至帳號設定 */
.theme-toggle {
    display: none; /* 隱藏，已移至帳號設定彈窗 */
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.theme-toggle:hover {
    transform: rotate(180deg);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.4);
}

/* 用戶資訊下拉選單 */
.user-info-dropdown {
    position: relative;
}

.user-info-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    cursor: pointer;
    color: inherit;
}

.user-info-btn:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.3);
}

.user-info-btn .user-arrow {
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
    margin-left: 0.3rem;
}

.user-info-dropdown.open .user-arrow {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    min-width: 200px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    overflow: hidden;
}

.user-info-dropdown.open .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-header {
    padding: 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.user-menu-email {
    font-size: 0.8rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.user-menu-item:hover {
    background: var(--bg-secondary);
}

.user-menu-item .menu-icon {
    font-size: 1rem;
}

.user-menu-item.logout {
    color: var(--risk-critical);
}

.user-menu-item.logout:hover {
    background: rgba(239, 68, 68, 0.1);
}

.user-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.3rem 0;
}

body.light-theme .user-dropdown-menu {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

/* 用戶資訊 (舊版相容) */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.user-info:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.3);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-status {
    font-size: 0.75rem;
    color: var(--risk-low);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.user-status::before {
    content: '●';
    font-size: 0.6rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.company-logo {
    height: 40px;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
}

/* Light 主題 */
body.light-theme .company-logo {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* 主要儀表板布局 - 4欄 grid */
.dashboard {
    padding: 2rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    max-width: 1800px;
    margin: 0 auto;
}

/* 一般卡片橫跨全部 4 欄 */
.dashboard > .card {
    grid-column: 1 / -1;
}

/* 風險卡片各佔 1 欄 */
.dashboard > .card.risk-card {
    grid-column: auto;
}

/* 卡片基本樣式 */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: move;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

body.light-theme .card {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover {
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
    transform: translateY(-2px);
}

.card:hover::before {
    opacity: 1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: nowrap;
    gap: 1rem;
}

.card-header h2,
.card-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    color: var(--text-primary);
}

.drag-handle {
    cursor: move;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 0.25rem;
    transition: color 0.3s ease;
}

.drag-handle:hover {
    color: var(--accent-cyan);
}

/* 卡片操作區 - 確保不換行 */
.card-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* 運行結構卡片 */
.architecture-card {
    grid-column: 1;
}

/* 運行模式三切開關容器 - 置中 */
.mode-switch-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.mode-switch-container .animation-toggle {
    margin-right: 0;
}

/* 套用按鈕 */
.apply-mode-btn {
    padding: 0.5rem 1.2rem;
    background: linear-gradient(135deg, #f97316, #ef4444);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: pulse-apply 1.5s infinite;
}

.apply-mode-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(249, 115, 22, 0.6);
}

@keyframes pulse-apply {
    0%, 100% { box-shadow: 0 0 5px rgba(249, 115, 22, 0.4); }
    50% { box-shadow: 0 0 15px rgba(249, 115, 22, 0.8); }
}

/* 運行模式三切開關 */
.mode-switch {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-secondary);
    padding: 0.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
}

.mode-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.mode-btn.active {
    color: white;
    font-weight: 600;
}

.mode-btn[data-mode="bypass"].active {
    background: #6b7280;
    box-shadow: 0 0 10px rgba(107, 114, 128, 0.5);
}

.mode-btn[data-mode="monitor"].active {
    background: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.5);
}

.mode-btn[data-mode="enforce"].active {
    background: var(--risk-critical);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.mode-icon {
    font-size: 1rem;
}

.mode-label {
    font-size: 0.8rem;
}

/* Import Data 按鈕（移至時間控制右側） */
.import-data-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.3);
    margin-left: 0.5rem;
}

.import-data-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.5);
}

.import-data-btn .btn-icon {
    font-size: 1rem;
}

/* 模式儲存按鈕 */
.mode-save-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: pulse-save 1.5s ease-in-out infinite;
}

.mode-save-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.6);
}

@keyframes pulse-save {
    0%, 100% {
        box-shadow: 0 0 5px rgba(0, 217, 255, 0.4);
    }
    50% {
        box-shadow: 0 0 15px rgba(0, 217, 255, 0.7);
    }
}

/* 預選狀態的模式按鈕（尚未儲存） */
.mode-btn.pending {
    position: relative;
}

.mode-btn.pending::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: var(--accent-cyan);
    border-radius: 50%;
    animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.architecture-diagram {
    position: relative;
    height: 620px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* Light 主題 - 運行結構背景修正 */
body.light-theme .architecture-diagram {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

body.light-theme .architecture-card {
    background: var(--bg-card);
}

body.light-theme .mode-switch {
    background: #f1f5f9;
}

body.light-theme .mode-btn {
    color: #64748b;
}

body.light-theme .mode-btn:hover {
    color: #334155;
    background: #e2e8f0;
}

#architectureCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* 主卡片樣式 */
.main-card {
    grid-column: 1;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-bottom: 2rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.stat-item:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.2);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 統計區塊垂直布局 */
.stats-grid-vertical {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-block {
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 0.8rem 1rem;
}

.stat-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.stat-block-header .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-block-header .stat-value {
    font-size: 1.8rem;
}

/* Agent 標題組（標題 + 排序按鈕） */
.agent-title-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Agent 排序按鈕 */
.agent-sort-options {
    display: flex;
    gap: 0.25rem;
}

.agent-sort-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.agent-sort-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.agent-sort-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.agent-sort-btn .sort-icon {
    font-size: 0.75rem;
}

.agent-sort-btn .sort-label {
    font-size: 0.65rem;
}

/* Request/Response/Block/Filter 子項目 */
.stat-sub-row {
    display: flex;
    justify-content: space-around;
    gap: 0.5rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-color);
}

.stat-sub-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    flex: 1;
}

.sub-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.sub-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-cyan);
}

.sub-value.block {
    color: var(--risk-critical);
}

.sub-value.filter {
    color: var(--risk-high);
}

/* 可點擊的統計項目 */
.stat-sub-item.clickable {
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.stat-sub-item.clickable:hover {
    background: var(--bg-card);
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.2);
}

/* 圖表區塊 */
.chart-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* 圖表切換標籤 */
.chart-tabs {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    padding: 0.3rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.chart-tab {
    padding: 0.4rem 0.8rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chart-tab:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.chart-tab.active {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: white;
    font-weight: 600;
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.3);
}

/* 圖表 Agent 選擇下拉選單 */
.chart-agent-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    font-size: 0.85rem;
}

.chart-agent-filter label {
    color: var(--text-muted);
    white-space: nowrap;
}

.chart-agent-filter select {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    min-width: 150px;
    transition: all 0.2s ease;
}

.chart-agent-filter select:hover {
    border-color: var(--accent-cyan);
}

.chart-agent-filter select:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 2px rgba(0, 217, 255, 0.2);
}

.chart-agent-filter select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Agent 卡片容器 - 支援拖曳 */
.agent-cards-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-color);
}

/* Agent 卡片空狀態 */
.agent-cards-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.agent-cards-empty .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.8rem;
    opacity: 0.6;
}

.agent-cards-empty .empty-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.agent-cards-empty .empty-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.agent-cards-empty .knowledge-link {
    color: var(--accent-cyan);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.agent-cards-empty .knowledge-link:hover {
    color: var(--accent-blue);
    text-decoration: underline;
}

/* Agent 卡片 - 支援拖曳 */
.agent-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.65rem;
    transition: all 0.2s ease;
    position: relative;
    cursor: grab;
    overflow: hidden;
    min-width: 0;
}

/* 為每張 Agent 卡片添加不同的背景色（使用 nth-child） */
.agent-card:nth-child(6n+1) {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.08) 0%, rgba(0, 217, 255, 0.02) 100%);
    border-color: rgba(0, 217, 255, 0.3);
}

.agent-card:nth-child(6n+2) {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.08) 0%, rgba(138, 43, 226, 0.02) 100%);
    border-color: rgba(138, 43, 226, 0.3);
}

.agent-card:nth-child(6n+3) {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.08) 0%, rgba(255, 107, 107, 0.02) 100%);
    border-color: rgba(255, 107, 107, 0.3);
}

.agent-card:nth-child(6n+4) {
    background: linear-gradient(135deg, rgba(46, 213, 115, 0.08) 0%, rgba(46, 213, 115, 0.02) 100%);
    border-color: rgba(46, 213, 115, 0.3);
}

.agent-card:nth-child(6n+5) {
    background: linear-gradient(135deg, rgba(255, 159, 67, 0.08) 0%, rgba(255, 159, 67, 0.02) 100%);
    border-color: rgba(255, 159, 67, 0.3);
}

.agent-card:nth-child(6n+6) {
    background: linear-gradient(135deg, rgba(96, 163, 188, 0.08) 0%, rgba(96, 163, 188, 0.02) 100%);
    border-color: rgba(96, 163, 188, 0.3);
}

.agent-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.agent-card.dragging {
    opacity: 0.5;
    transform: rotate(3deg) scale(1.02);
    cursor: grabbing;
    z-index: 100;
}

.agent-card.drag-over {
    border: 2px dashed var(--accent-cyan);
    background: rgba(0, 217, 255, 0.1);
}

.agent-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
    min-width: 0;
}

.agent-card-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.agent-card-name {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    white-space: nowrap;
    min-width: 0;
    position: relative;
}

/* Agent 名稱跑馬燈容器 */
.agent-card-name-inner {
    display: inline-block;
    white-space: nowrap;
}

/* 跑馬燈動畫 - 當名稱過長時啟用 */
.agent-card-name.marquee .agent-card-name-inner {
    animation: agent-name-marquee 6s linear infinite;
    padding-right: 2rem;
}

.agent-card-name.marquee:hover .agent-card-name-inner {
    animation-play-state: paused;
}

@keyframes agent-name-marquee {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

.agent-card-edit {
    flex-shrink: 0;
    font-size: 0.85rem;
    opacity: 0.6;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.2rem;
}

.agent-card-edit:hover {
    opacity: 1;
}

/* Agent 卡片 Request/Response 統計 */
.agent-card-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 0.4rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-color);
}

.agent-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.agent-stat-item:hover {
    background: var(--bg-secondary);
    transform: scale(1.05);
}

.agent-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.agent-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.agent-stat-value.request {
    color: var(--accent-cyan);
}

.agent-stat-value.response {
    color: var(--accent-purple);
}

/* Agent 卡片風險統計 - 加大字體 */
.agent-card-risks {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.25rem;
    margin-bottom: 0.35rem;
}

.agent-risk-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    padding: 0.2rem 0.3rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.agent-risk-item:hover {
    background: var(--bg-card);
    transform: scale(1.03);
    box-shadow: 0 0 8px rgba(0, 217, 255, 0.2);
}

.agent-risk-icon {
    font-size: 0.75rem;
}

.agent-risk-value {
    font-weight: 700;
    font-size: 0.95rem;
}

.agent-risk-value.critical { color: var(--risk-critical); }
.agent-risk-value.high { color: var(--risk-high); }
.agent-risk-value.medium { color: var(--risk-medium); }
.agent-risk-value.low { color: var(--risk-low); }

/* Agent 卡片底部區域 */
.agent-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border-color);
}

/* Agent 卡片動作統計 */
.agent-card-actions {
    display: flex;
    gap: 0.5rem;
}

.agent-action-item {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.agent-action-item:hover {
    background: var(--bg-secondary);
    transform: scale(1.05);
}

.agent-action-value {
    font-weight: 700;
    font-size: 0.85rem;
}

.agent-action-value.block { color: var(--risk-critical); }
.agent-action-value.filter { color: var(--risk-high); }

/* Agent 卡片時間顯示 */
.agent-card-time {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.agent-card-time .time-icon {
    font-size: 0.6rem;
    opacity: 0.7;
}

.agent-card-time .time-value {
    font-size: 0.6rem;
    white-space: nowrap;
}

/* 主卡片高度調整 */
.main-card .card-body {
    min-height: auto;
}

/* 圖表容器 */
.chart-container {
    height: 200px;
    position: relative;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.chart-container.small {
    height: 150px;
    margin-bottom: 1.5rem;
}

canvas {
    width: 100% !important;
    height: 100% !important;
}


.risk-card .card-body {
    text-align: center;
    position: relative;
    min-height: 100px;
    display: block;
    padding: 0.5rem;
    padding-bottom: 3rem; /* 為設定按鈕留空間 */
}

/* 風險卡片標題樣式 */
.risk-card .card-header h3 {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0;
}

.risk-icon {
    font-size: 1rem;
}

.risk-title {
    font-size: 1rem;
    font-weight: 600;
}

.edit-title-btn {
    font-size: 0.7rem;
    opacity: 0.5;
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.edit-title-btn:hover {
    opacity: 1;
    background: var(--bg-secondary);
}

/* 全域動作標籤 */
.global-action-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.global-action-badge.action-pass {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.4);
}

.global-action-badge.action-filter {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
    border-color: rgba(234, 179, 8, 0.4);
}

.global-action-badge.action-block {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.4);
}

.global-action-badge.action-bypass {
    background: rgba(156, 163, 175, 0.2);
    color: #9ca3af;
    border-color: rgba(156, 163, 175, 0.4);
}

/* 編輯模式 */
.risk-title-input {
    background: var(--bg-secondary);
    border: 1px solid var(--accent-cyan);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.2rem 0.4rem;
    width: 80px;
    outline: none;
}

.risk-number {
    font-size: 3rem;
    font-weight: 700;
    margin: 1rem 0;
    transition: transform 0.3s ease;
}

.risk-card:hover .risk-number {
    transform: scale(1.1);
}

.risk-card.critical .risk-number {
    color: var(--risk-critical);
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

.risk-card.high .risk-number {
    color: var(--risk-high);
    text-shadow: 0 0 20px rgba(249, 115, 22, 0.5);
}

.risk-card.medium .risk-number {
    color: var(--risk-medium);
    text-shadow: 0 0 20px rgba(234, 179, 8, 0.5);
}

.risk-card.low .risk-number {
    color: var(--risk-low);
    text-shadow: 0 0 20px rgba(34, 197, 94, 0.5);
}

.risk-update {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* 最後新增顯示 */
.last-added {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.4rem;
    font-size: 0.7rem;
}

.last-added-time {
    color: var(--accent-cyan);
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.last-added-category {
    background: var(--bg-secondary);
    padding: 0.15rem 0.4rem;
    border-radius: 8px;
    color: var(--text-secondary);
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.risk-card.critical .last-added-category {
    border: 1px solid var(--risk-critical);
    color: var(--risk-critical);
}
.risk-card.high .last-added-category {
    border: 1px solid var(--risk-high);
    color: var(--risk-high);
}
.risk-card.medium .last-added-category {
    border: 1px solid var(--risk-medium);
    color: var(--risk-medium);
}
.risk-card.low .last-added-category {
    border: 1px solid var(--risk-low);
    color: var(--risk-low);
}

/* 前三大異常類別 - 跑馬燈容器 */
.top-categories {
    position: relative;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    overflow: hidden;
    width: 100%;
    min-height: 24px;
    display: flex;
    align-items: center;
}

/* 跑馬燈內容軌道 - 無縫循環 */
.top-categories .marquee-track {
    display: inline-flex;
    gap: 1.2rem;
    animation: marquee-scroll 12s linear infinite;
    white-space: nowrap;
    will-change: transform;
    align-items: center;
}

/* 跑馬燈動畫 - 移動內容一半的距離實現無縫循環 */
@keyframes marquee-scroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* 滑鼠懸停暫停跑馬燈 */
.top-categories:hover .marquee-track {
    animation-play-state: paused;
}

/* 當內容較少時不跑馬燈，置中顯示 */
.top-categories.no-scroll {
    justify-content: center;
    overflow: visible;
}

.top-categories.no-scroll .marquee-track {
    animation: none;
}

.category-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.45rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.73rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.category-tag:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.3);
}

.category-tag .tag-name {
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-tag .tag-count {
    background: var(--bg-card);
    padding: 0.1rem 0.3rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.65rem;
}

/* 風險等級對應顏色 */
.risk-card.critical .category-tag:hover {
    border-color: var(--risk-critical);
    background: rgba(239, 68, 68, 0.15);
}
.risk-card.critical .category-tag .tag-count {
    color: var(--risk-critical);
}

.risk-card.high .category-tag:hover {
    border-color: var(--risk-high);
    background: rgba(249, 115, 22, 0.15);
}
.risk-card.high .category-tag .tag-count {
    color: var(--risk-high);
}

.risk-card.medium .category-tag:hover {
    border-color: var(--risk-medium);
    background: rgba(234, 179, 8, 0.15);
}
.risk-card.medium .category-tag .tag-count {
    color: var(--risk-medium);
}

.risk-card.low .category-tag:hover {
    border-color: var(--risk-low);
    background: rgba(34, 197, 94, 0.15);
}
.risk-card.low .category-tag .tag-count {
    color: var(--risk-low);
}

/* 無類別資料提示 */
.no-categories {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.settings-btn {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: transparent;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.3s ease;
    padding: 0.2rem;
    border-radius: 50%;
    z-index: 10;
}

.settings-btn:hover {
    color: var(--accent-cyan);
    background: var(--bg-secondary);
    transform: rotate(90deg);
}

/* 風險卡片點擊效果 */
.risk-card {
    cursor: pointer;
}

.risk-card.active {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 30px rgba(0, 217, 255, 0.4);
}

/* 詳情卡片 */
.detail-card {
    grid-column: 1;
    position: relative;
}

.table-container {
    overflow-x: auto;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.conversation-table {
    width: 100%;
    border-collapse: collapse;
}

.conversation-table thead {
    background: var(--bg-primary);
    position: sticky;
    top: 0;
}

.conversation-table th {
    padding: 0.75rem 0.5rem;
    text-align: left;
    font-weight: 600;
    color: var(--accent-cyan);
    border-bottom: 2px solid var(--accent-cyan);
    white-space: nowrap;
}

/* 表頭內容結構 */
.th-content {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.th-text {
    flex-shrink: 0;
}

.th-icons {
    display: flex;
    gap: 0.15rem;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.conversation-table th:hover .th-icons {
    opacity: 1;
}

.sort-icon, .filter-icon, .search-icon {
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0.15rem;
    border-radius: 3px;
    transition: all 0.2s ease;
    user-select: none;
}

.sort-icon:hover, .filter-icon:hover, .search-icon:hover {
    background: var(--bg-secondary);
    transform: scale(1.1);
}

.sort-icon.active {
    color: var(--accent-blue);
    background: rgba(37, 99, 235, 0.2);
}

.sort-icon.asc::after {
    content: '↑';
    margin-left: 2px;
}

.sort-icon.desc::after {
    content: '↓';
    margin-left: 2px;
}

.filter-icon.active, .search-icon.active {
    color: var(--risk-high);
    background: rgba(249, 115, 22, 0.2);
}

.conversation-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.conversation-table tbody tr {
    transition: background 0.2s ease;
}

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

.no-data {
    text-align: center !important;
    color: var(--text-muted);
    padding: 2rem !important;
}

/* 風險標籤 */
.risk-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    margin: 1px 2px;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.risk-badge.critical {
    background: rgba(239, 68, 68, 0.2);
    color: var(--risk-critical);
    border: 1px solid var(--risk-critical);
}

.risk-badge.high {
    background: rgba(249, 115, 22, 0.2);
    color: var(--risk-high);
    border: 1px solid var(--risk-high);
}

.risk-badge.medium {
    background: rgba(234, 179, 8, 0.2);
    color: var(--risk-medium);
    border: 1px solid var(--risk-medium);
}

.risk-badge.low {
    background: rgba(34, 197, 94, 0.2);
    color: var(--risk-low);
    border: 1px solid var(--risk-low);
}

/* Action 標籤 */
.action-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: default;
    position: relative;
}

.action-badge.filter {
    background: rgba(249, 115, 22, 0.2);
    color: var(--risk-high);
    border: 1px solid var(--risk-high);
    cursor: help;
}

.action-badge.block {
    background: rgba(239, 68, 68, 0.2);
    color: var(--risk-critical);
    border: 1px solid var(--risk-critical);
}

.action-badge.pass {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
    border: 1px solid #6b7280;
}

/* Category badge */
.category-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Filter tooltip */
.action-badge.filter .filter-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    border: 1px solid var(--risk-high);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: normal;
    white-space: nowrap;
    z-index: 100;
    margin-bottom: 5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.action-badge.filter .filter-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--risk-high);
}

.action-badge.filter:hover .filter-tooltip {
    visibility: visible;
    opacity: 1;
}

.filter-tooltip .original {
    color: var(--text-muted);
    text-decoration: line-through;
    margin-right: 0.5rem;
}

.filter-tooltip .replaced {
    color: var(--risk-high);
    font-weight: 600;
}

.filter-tooltip .arrow {
    color: var(--text-muted);
    margin: 0 0.3rem;
}

/* 過濾/搜尋浮動框 */
.table-filter-popup {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    min-width: 220px;
    max-width: 300px;
    width: 280px;
}

.filter-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.8rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.filter-popup-header .close-btn {
    font-size: 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.filter-popup-body {
    padding: 0.8rem;
    max-height: 350px;
    overflow-y: auto;
}

.filter-popup-body input {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.filter-popup-body input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

.filter-options {
    max-height: 350px;
    overflow-y: auto;
    margin-top: 0.5rem;
}

.filter-options::-webkit-scrollbar {
    width: 6px;
}

.filter-options::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.filter-options::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: background 0.2s ease;
}

.filter-option:hover {
    background: var(--bg-secondary);
}

.filter-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    cursor: pointer;
    accent-color: var(--accent-cyan);
}

.filter-option span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-options .no-options {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-align: center;
    padding: 1rem;
}

/* 風險類別分組樣式 */
.category-group {
    margin-bottom: 0.25rem;
}

.category-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: var(--bg-secondary);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    font-size: 0.8rem;
    font-weight: 500;
}

.category-group-header:hover {
    background: var(--bg-tertiary);
}

.group-toggle {
    font-size: 0.7rem;
    color: var(--text-muted);
    width: 12px;
}

.group-name {
    font-weight: 600;
}

.group-count {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-left: auto;
}

.category-group-items {
    padding-left: 0.5rem;
    border-left: 1px solid var(--border-color);
    margin-left: 0.6rem;
}

.category-group-items .filter-option {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
}

/* 詳情彈窗風險類別分組樣式 */
.detail-category-groups {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-category-group {
    border-radius: 6px;
    overflow: hidden;
}

.detail-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg-secondary);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.detail-group-header:hover {
    background: var(--bg-tertiary);
}

.detail-group-toggle {
    font-size: 0.65rem;
    color: var(--text-muted);
    width: 12px;
}

.detail-group-name {
    font-weight: 600;
    font-size: 0.8rem;
}

.detail-group-count {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.detail-group-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.5rem 0.6rem;
    padding-left: 1.5rem;
    background: var(--bg-primary);
}

.detail-group-items .risk-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
}

.filter-popup-footer {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
    border-top: 1px solid var(--border-color);
    justify-content: flex-end;
    background: var(--bg-card);
    border-radius: 0 0 8px 8px;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

/* 表格載入動畫 */
.table-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 1rem;
}

.table-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: table-spin 0.8s linear infinite;
}

@keyframes table-spin {
    to { transform: rotate(360deg); }
}

.table-loading-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.table-loading-dots {
    display: inline-flex;
    gap: 4px;
}

.table-loading-dots span {
    width: 6px;
    height: 6px;
    background: var(--accent-cyan);
    border-radius: 50%;
    animation: table-dots 1.4s infinite ease-in-out;
}

.table-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.table-loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.table-loading-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes table-dots {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* 來源標籤 */
.source-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.source-badge.user {
    background: rgba(0, 217, 255, 0.2);
    color: var(--accent-cyan);
    border: 1px solid var(--accent-cyan);
}

/* Agent 標籤 */
.agent-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid;
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 查看詳情按鈕 */
.view-btn {
    padding: 0.4rem 0.8rem;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.view-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.4);
}

/* 狀態標記 */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.online {
    background: rgba(34, 197, 94, 0.2);
    color: var(--risk-low);
    border: 1px solid var(--risk-low);
}

.status-badge.offline {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
    border: 1px solid #9ca3af;
}

/* 摘要行 */
.summary-row td {
    background: var(--bg-primary) !important;
    color: var(--accent-cyan) !important;
    font-size: 1rem;
}

.source-badge.agent {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-purple);
    border: 1px solid var(--accent-purple);
}

.source-badge.system {
    background: rgba(156, 163, 175, 0.2);
    color: #9ca3af;
    border: 1px solid #9ca3af;
}

/* 密碼輸入視窗 */
.password-modal-content {
    max-width: 400px !important;
}

.password-modal-content .modal-body {
    text-align: center;
}

.password-modal-content .modal-body p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.password-modal-content .modal-body strong {
    color: var(--accent-cyan);
}

.password-input-container {
    margin: 1.5rem 0;
}

.password-input {
    width: 100%;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 0.5rem;
    transition: all 0.3s ease;
}

.password-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.3);
}

.password-input::placeholder {
    letter-spacing: normal;
    font-size: 0.9rem;
}

.password-hint {
    min-height: 1.5rem;
    font-size: 0.9rem;
}

/* Toast 提示 */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: white;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0, 217, 255, 0.4);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 3000;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 彈窗樣式 */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--accent-cyan);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: auto;
    box-shadow: 0 0 40px rgba(0, 217, 255, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s ease;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: var(--risk-critical);
}

.modal-body {
    padding: 1.5rem;
}

.settings-group {
    margin-bottom: 1.5rem;
}

.settings-group label {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.settings-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

/* 設定彈窗新樣式 */
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.settings-label {
    display: flex !important;
    align-items: center;
    color: var(--text-primary) !important;
    font-weight: 500;
    margin-bottom: 0 !important;
}

.settings-sublabel {
    font-size: 0.85rem;
    color: var(--text-muted) !important;
    margin-top: 0.5rem;
}

/* 通知頻道按鈕 */
.notify-channels {
    display: flex;
    gap: 0.5rem;
}

.channel-btn {
    padding: 0.4rem 0.8rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.channel-btn:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    background: rgba(0, 217, 255, 0.1);
}

/* 企業版專屬功能按鈕 */
.channel-btn.enterprise-feature {
    position: relative;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.enterprise-badge {
    display: block;
    font-size: 0.6rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* 企業版專屬區塊 */
.enterprise-section {
    position: relative;
}

.enterprise-section .settings-label .enterprise-badge {
    margin-left: 0.5rem;
    font-size: 0.7rem;
}

.enterprise-section .add-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.enterprise-section input:disabled + span {
    opacity: 0.6;
}

/* 企業版功能禁用覆蓋層 */
.enterprise-disabled-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    z-index: 10;
}

.enterprise-disabled-overlay span {
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* 全域動作三切開關 */
.action-switch {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 3px;
    border: 1px solid var(--border-color);
}

.action-btn {
    padding: 0.4rem 1rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    color: var(--text-primary);
}

.action-btn.active {
    background: var(--accent-blue);
    color: white;
    font-weight: 600;
}

.action-btn[data-action="bypass"].active {
    background: #6b7280;
}

.action-btn[data-action="filter"].active {
    background: var(--risk-high);
}

.action-btn[data-action="block"].active {
    background: var(--risk-critical);
}

/* 全域動作停用狀態 */
.action-switch.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.action-switch.disabled .action-btn {
    cursor: not-allowed;
}

.settings-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: normal;
    margin-left: 0.5rem;
}

/* Filter 替換關鍵字區塊 */
.filter-replace-section {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* Filter 預設說明文字 */
.filter-default-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0 0 0.75rem 0;
    padding: 0;
}

/* Block 設定區塊 */
.block-settings-section {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.block-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.block-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.block-option:hover {
    border-color: var(--accent-cyan);
    background: rgba(0, 217, 255, 0.05);
}

.block-option input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-cyan);
    cursor: pointer;
}

.block-option .option-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.block-option .option-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: normal;
}

.block-custom-message {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.custom-message-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.block-custom-message textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    font-family: inherit;
}

.block-custom-message textarea:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 2px rgba(0, 217, 255, 0.1);
}

.block-custom-message textarea::placeholder {
    color: var(--text-muted);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.section-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.add-btn {
    padding: 0.3rem 0.6rem;
    background: var(--accent-blue);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-btn:hover {
    background: var(--accent-cyan);
    transform: scale(1.02);
}

/* 替換規則 */
.replace-rules {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.replace-rule {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-card);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.replace-rule .category-select {
    flex: 1;
    min-width: 150px;
    padding: 0.4rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.replace-rule .category-select:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

.replace-rule .category-select optgroup {
    font-weight: bold;
    color: var(--text-secondary);
}

.replace-rule .category-select option {
    font-weight: normal;
    color: var(--text-primary);
}

.replace-rule input {
    flex: 1;
    padding: 0.4rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.replace-rule input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

.replace-rule .arrow {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.replace-rule select {
    width: 100px;
    padding: 0.4rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.replace-rule .custom-value {
    width: 80px;
}

.replace-rule .custom-value.input-error {
    border: 2px solid var(--risk-critical) !important;
    background-color: rgba(239, 68, 68, 0.1);
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.replace-rule .delete-btn {
    padding: 0.3rem 0.5rem;
    background: transparent;
    border: 1px solid var(--risk-critical);
    border-radius: 4px;
    color: var(--risk-critical);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.replace-rule .delete-btn:hover {
    background: var(--risk-critical);
    color: white;
}

/* 自定義監控規則 */
.monitor-rules {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
    max-height: 250px;
    overflow-y: auto;
}

.monitor-rule {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.monitor-rule .tag-select {
    width: 140px;
    padding: 0.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.monitor-rule .keyword-input {
    flex: 1;
    padding: 0.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.8rem;
    min-width: 100px;
}

.monitor-rule .keyword-input:focus,
.monitor-rule .tag-select:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

.monitor-rule .fuzzy-toggle {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.monitor-rule .fuzzy-toggle input {
    width: 14px;
    height: 14px;
}

.monitor-rule .delete-btn {
    padding: 0.3rem 0.5rem;
    background: transparent;
    border: 1px solid var(--risk-critical);
    border-radius: 4px;
    color: var(--risk-critical);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.monitor-rule .delete-btn:hover {
    background: var(--risk-critical);
    color: white;
}

/* 空狀態提示 */
.empty-hint {
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* 子彈窗 */
.sub-modal {
    z-index: 2500;
}

.modal-content.small {
    max-width: 550px;
    max-height: 85vh;
}

.modal-header h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 0;
}

/* 通知設定欄位 */
.notify-config-section {
    padding: 0.5rem 0;
}

.config-field {
    margin-bottom: 1rem;
}

.config-field label {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.config-field input[type="email"],
.config-field input[type="url"],
.config-field input[type="tel"],
.config-field select {
    width: 100%;
    padding: 0.6rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.config-field input:focus,
.config-field select:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

/* 郵件設定樣式 */
.email-intro {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.intro-text {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

.email-rule {
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    background: var(--bg-secondary);
    cursor: pointer;
}

.rule-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 !important;
}

.rule-title {
    font-weight: 500;
    color: var(--text-primary);
}

.rule-expand {
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: transform 0.2s ease;
    cursor: pointer;
}

.rule-body {
    padding: 1rem;
    background: var(--bg-card);
    transition: all 0.3s ease;
}

.rule-body.collapsed {
    display: none;
}

.config-field .hint {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: normal;
}

/* 收件人輸入欄位 (多行文字) */
.email-recipients-input {
    width: 100%;
    padding: 0.6rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    resize: vertical;
    min-height: 50px;
}

.email-recipients-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

/* 郵件標題輸入欄位 (加寬加高) */
.email-title-input {
    width: 100%;
    padding: 0.6rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    min-height: 48px;
    line-height: 1.4;
}

.email-title-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

/* 郵件內文輸入欄位 */
.email-body-input {
    width: 100%;
    padding: 0.6rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    resize: vertical;
}

.email-body-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

/* 變數說明區塊 */
.variable-help {
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    background: var(--bg-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.help-expand {
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}

.help-body {
    padding: 0.8rem 1rem;
    background: var(--bg-card);
}

.help-body.collapsed {
    display: none;
}

.variable-table {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: collapse;
}

.variable-table tr {
    border-bottom: 1px solid var(--border-color);
}

.variable-table tr:last-child {
    border-bottom: none;
}

.variable-table td {
    padding: 0.4rem 0;
}

.variable-table td:first-child {
    width: 45%;
}

.variable-table code {
    background: var(--bg-secondary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    color: var(--accent-cyan);
    font-size: 0.75rem;
}

.threshold-input,
.keyword-input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 6px;
    font-family: inherit;
}

.threshold-input:focus,
.keyword-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.btn {
    padding: 0.5rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.5);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--accent-cyan);
}

/* ==================== 新建專案彈窗 ==================== */
.create-project-modal {
    max-width: 450px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.1);
}

.form-input::placeholder {
    color: var(--text-secondary);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.4rem;
}

.form-error {
    font-size: 0.8rem;
    color: #ef4444;
    margin-top: 0.4rem;
    min-height: 1.2em;
}

.form-input.error {
    border-color: #ef4444;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
    max-height: 200px;
    font-family: inherit;
    line-height: 1.5;
}

/* 專案選項樣式 - 拖曳和刪除 */
.project-option {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.project-drag-handle {
    cursor: grab;
    color: var(--text-secondary);
    opacity: 0.5;
    font-size: 14px;
    padding: 2px 4px;
    transition: opacity 0.2s;
    user-select: none;
}

.project-option:hover .project-drag-handle {
    opacity: 1;
}

.project-drag-handle:active {
    cursor: grabbing;
}

.project-option-name {
    flex: 1;
    cursor: pointer;
}

.project-delete-btn {
    opacity: 0;
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    transition: opacity 0.2s, transform 0.2s;
    border-radius: 4px;
}

.project-option:hover .project-delete-btn {
    opacity: 0.6;
}

.project-delete-btn:hover {
    opacity: 1 !important;
    transform: scale(1.1);
    background: rgba(239, 68, 68, 0.2);
}

.project-option.dragging {
    opacity: 0.5;
    background: var(--bg-tertiary);
}

.project-option.drag-over {
    border-top: 2px solid var(--accent-cyan);
}

/* 刪除專案彈窗 */
.delete-project-modal,
.delete-password-modal {
    max-width: 450px;
}

.modal-header-danger {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
}

.modal-header-danger h2 {
    color: #fff;
}

.delete-warning {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.warning-text {
    color: #ef4444;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.project-to-delete {
    color: var(--text-secondary);
}

.project-to-delete strong {
    color: var(--text-primary);
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: #fff;
    border: none;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    transform: translateY(-1px);
}

/* 設定密碼彈窗 */
.set-password-modal {
    max-width: 420px;
}

.password-description,
.password-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

/* 公司密碼提示區塊 */
.company-password-notice {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.15), rgba(255, 152, 0, 0.1));
    border: 1px solid rgba(255, 193, 7, 0.4);
    border-left: 4px solid #ffc107;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.company-password-notice .notice-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.company-password-notice span:last-child {
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.5;
}

.company-password-notice strong {
    color: #ffc107;
    font-weight: 600;
}

/* 拖曳效果 */
.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.drag-over {
    border: 2px dashed var(--accent-cyan);
    box-shadow: 0 0 30px rgba(0, 217, 255, 0.4);
}

/* 卡片底部按鈕區 */
.card-bottom-actions {
    position: absolute;
    bottom: 2px;
    right: 2px;
    display: flex;
    gap: 0.3rem;
    z-index: 10;
}

.category-switch-btn {
    background: transparent;
    border: none;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.3s ease;
    padding: 0.2rem;
    border-radius: 50%;
}

.category-switch-btn:hover {
    color: var(--accent-cyan);
    background: var(--bg-secondary);
    transform: scale(1.1);
}

.card-bottom-actions .settings-btn {
    position: static;
}

/* ==================== 風險項目切換彈窗 ==================== */
.category-switch-modal {
    max-width: 900px;
    width: 95%;
}

.category-switch-body {
    display: flex;
    gap: 1.5rem;
    min-height: 400px;
    padding: 1rem 0;
}

/* 左側：來源面板 */
.category-source-panel {
    flex: 1;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.panel-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.panel-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
}

.category-list {
    flex: 1;
    padding: 0.8rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* 可拖曳的類別項目 */
.category-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: grab;
    transition: all 0.2s ease;
}

.category-item:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.2);
    transform: translateX(3px);
}

.category-item:active {
    cursor: grabbing;
}

.category-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg) scale(1.02);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.category-item .drag-icon {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.category-item .category-name {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.category-item .category-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.15rem 0.5rem;
    border-radius: 8px;
}

/* 右側：目標面板區 */
.category-target-panels {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.target-panel {
    flex: 1;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}

.target-panel.critical {
    border-color: rgba(239, 68, 68, 0.3);
}

.target-panel.high {
    border-color: rgba(249, 115, 22, 0.3);
}

.target-panel.medium {
    border-color: rgba(234, 179, 8, 0.3);
}

.target-panel.low {
    border-color: rgba(34, 197, 94, 0.3);
}

.target-panel.hidden {
    display: none;
}

.target-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.target-icon {
    font-size: 0.9rem;
}

.target-title {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.target-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.15rem 0.5rem;
    border-radius: 8px;
    min-width: 24px;
    text-align: center;
}

/* 放置區域 */
.target-dropzone {
    flex: 1;
    padding: 0.5rem;
    min-height: 60px;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-content: flex-start;
    transition: all 0.3s ease;
}

.target-dropzone.drag-over {
    background: rgba(0, 217, 255, 0.1);
    border: none;
    box-shadow: inset 0 0 20px rgba(0, 217, 255, 0.2);
}

.target-panel.critical .target-dropzone.drag-over {
    background: rgba(239, 68, 68, 0.1);
    box-shadow: inset 0 0 20px rgba(239, 68, 68, 0.2);
}

.target-panel.high .target-dropzone.drag-over {
    background: rgba(249, 115, 22, 0.1);
    box-shadow: inset 0 0 20px rgba(249, 115, 22, 0.2);
}

.target-panel.medium .target-dropzone.drag-over {
    background: rgba(234, 179, 8, 0.1);
    box-shadow: inset 0 0 20px rgba(234, 179, 8, 0.2);
}

.target-panel.low .target-dropzone.drag-over {
    background: rgba(34, 197, 94, 0.1);
    box-shadow: inset 0 0 20px rgba(34, 197, 94, 0.2);
}

.dropzone-hint {
    width: 100%;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.5rem;
    opacity: 0.6;
}

/* 放置區域中的項目（小型化） */
.target-dropzone .category-item {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

.target-dropzone .category-item .category-name {
    font-size: 0.75rem;
}

.target-dropzone .category-item .category-count {
    font-size: 0.65rem;
    padding: 0.1rem 0.35rem;
}

.target-dropzone .category-item .drag-icon {
    font-size: 0.75rem;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .header-right {
        flex-wrap: wrap;
        justify-content: center;
    }

    .logo-text {
        font-size: 1.5rem;
    }

    /* 小螢幕時 dashboard 改為 2 欄 */
    .dashboard {
        grid-template-columns: repeat(2, 1fr);
    }

    /* 風險卡片在小螢幕各佔 1 欄 (2x2 網格) */
    .dashboard > .card.risk-card {
        grid-column: auto;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Agent 卡片小螢幕改為 2 欄 */
    .agent-cards-container {
        grid-template-columns: repeat(2, 1fr);
    }

    /* 統計子項目小螢幕改為換行 */
    .stat-sub-row {
        flex-wrap: wrap;
    }

    .stat-sub-item {
        flex: 1 1 40%;
    }

    .dashboard {
        padding: 1rem;
    }

    .architecture-diagram {
        height: 150px;
    }
}

/* 滾動條樣式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-cyan);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

/* ==================== Agent 編輯彈窗 ==================== */
.edit-agent-modal {
    max-width: 500px;
}

.color-picker {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.8rem;
    margin-top: 0.5rem;
}

.color-option {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.color-option:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.color-option.selected {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 4px rgba(0, 217, 255, 0.2);
    transform: scale(1.05);
}

.icon-picker {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.8rem;
    margin-top: 0.5rem;
}

.icon-option {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    background: var(--bg-secondary);
    border: 3px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-option:hover {
    transform: scale(1.1);
    background: var(--bg-card);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.icon-option.selected {
    border-color: var(--accent-cyan);
    background: var(--bg-card);
    box-shadow: 0 0 0 4px rgba(0, 217, 255, 0.2);
    transform: scale(1.05);
}

/* ==================== 名稱編輯彈窗 ==================== */
.edit-name-modal {
    max-width: 400px;
}

.edit-name-input {
    width: 100%;
    padding: 0.8rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.edit-name-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.2);
}

/* ==================== 密碼驗證彈窗 ==================== */
.password-modal {
    max-width: 400px;
}

.password-info {
    text-align: center;
    margin-bottom: 1rem;
    padding: 0.8rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.password-info p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.target-mode {
    font-weight: 600;
    color: var(--accent-cyan);
}

.target-mode.bypass {
    color: #6b7280;
}

.target-mode.monitor {
    color: var(--accent-blue);
}

.target-mode.enforce {
    color: var(--risk-critical);
}

.password-input {
    width: 100%;
    padding: 0.8rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.password-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.2);
}

.password-error {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--risk-critical);
    border-radius: 6px;
    color: var(--risk-critical);
    font-size: 0.85rem;
    text-align: center;
}

/* ==================== 數量切換按鈕 ==================== */
.page-size-switch {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-secondary);
    padding: 0.2rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-right: 1rem;
}

.page-size-btn {
    padding: 0.3rem 0.6rem;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

.page-size-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.page-size-btn.active {
    background: var(--accent-cyan);
    color: white;
}

/* ==================== 翻頁控制區 ==================== */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-top: 1rem;
    border: 1px solid var(--border-color);
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pagination-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--accent-cyan);
    background: rgba(0, 217, 255, 0.1);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-indicator {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0 0.5rem;
}

/* ==================== 靜態/動態切換開關 ==================== */
.animation-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 1rem;
}

.toggle-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 22px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: white;
}

/* ==================== 獎盃統計 ==================== */
.trophy-stats {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.2), rgba(255, 152, 0, 0.2));
    border: 1px solid #ffc107;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.trophy-stats:hover {
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.4);
    transform: scale(1.05);
}

.trophy-icon {
    font-size: 1.3rem;
}

.trophy-count {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffc107;
    text-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

/* 帳號設定彈窗 */
.user-settings-modal {
    max-width: 600px;
}

.settings-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.settings-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.settings-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 使用者資訊 */
.settings-user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.settings-avatar {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    border-radius: 50%;
}

.settings-user-details {
    flex: 1;
}

.settings-user-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.settings-user-email {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* 設定項目 */
.settings-item {
    margin-bottom: 1.25rem;
}

.settings-item:last-child {
    margin-bottom: 0;
}

.settings-item-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.settings-icon {
    font-size: 1.1rem;
}

/* 主題切換按鈕 */
.settings-theme-toggle {
    display: flex;
    gap: 0.75rem;
}

.theme-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.theme-option:hover {
    border-color: var(--accent-cyan);
    color: var(--text-primary);
}

.theme-option.active {
    border-color: var(--accent-cyan);
    background: rgba(0, 217, 255, 0.1);
    color: var(--accent-cyan);
}

.theme-option-icon {
    font-size: 1.2rem;
}

/* 語言選擇網格 */
.settings-language-select {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.language-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.language-option:hover {
    border-color: var(--accent-cyan);
    color: var(--text-primary);
}

.language-option.active {
    border-color: var(--accent-cyan);
    background: rgba(0, 217, 255, 0.1);
    color: var(--accent-cyan);
}

.language-option .lang-flag {
    font-size: 1.1rem;
}

/* 時區選擇 */
.settings-timezone-select {
    width: 100%;
}

.timezone-dropdown {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2399a1af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.timezone-dropdown:hover {
    border-color: var(--accent-cyan);
}

.timezone-dropdown:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.1);
}

.timezone-dropdown option {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.5rem;
}

/* API Key 管理按鈕 */
.api-key-manage-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* API Key 管理彈窗 */
.api-key-modal {
    max-width: 700px;
    width: 95%;
}

.api-key-list-section {
    margin-bottom: 1.5rem;
}

.api-key-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.api-key-list-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.api-key-list {
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    max-height: 300px;
    overflow-y: auto;
}

.api-key-loading,
.api-key-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.api-key-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

.api-key-item:last-child {
    border-bottom: none;
}

.api-key-item:hover {
    background: var(--bg-tertiary);
}

.api-key-info {
    flex: 1;
    min-width: 0;
}

.api-key-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.api-key-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.api-key-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.api-key-preview {
    font-family: monospace;
    background: var(--bg-primary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.api-key-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
}

.api-key-actions .btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

.api-key-status {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.api-key-status.active {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.api-key-status.expired {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.api-key-status.inactive {
    background: rgba(156, 163, 175, 0.2);
    color: #9ca3af;
}

/* API Key 表單 */
.api-key-form-section {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 1.5rem;
    margin-top: 1rem;
    border: 1px solid var(--border-color);
}

.api-key-form-section h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.api-key-form .form-group {
    margin-bottom: 1rem;
}

.api-key-form .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.api-key-form .form-input,
.api-key-form .form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color 0.2s ease;
}

.api-key-form .form-input:focus,
.api-key-form .form-select:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

.api-key-form .form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2399a1af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

.api-key-form .form-textarea {
    resize: vertical;
    min-height: 80px;
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.api-key-form .form-hint {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* 必填/選填欄位標記 */
.api-key-form .form-group label .required-marker {
    color: #ef4444;
    font-weight: 600;
    margin-left: 0.25rem;
}

.api-key-form .form-group label .optional-marker {
    color: var(--text-secondary);
    font-weight: normal;
    font-size: 0.85em;
    margin-left: 0.5rem;
}

.api-key-form .form-group.required label {
    color: var(--text-primary);
}

.api-key-form .form-group.required label::after {
    content: ' *';
    color: #ef4444;
    font-weight: 600;
}

.api-key-form .form-group.required .form-input,
.api-key-form .form-group.required .form-select {
    border-color: rgba(239, 68, 68, 0.4);
}

.api-key-form .form-group.required .form-input:focus,
.api-key-form .form-group.required .form-select:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.api-key-form .form-group.optional label {
    color: var(--text-secondary);
}

.api-key-form .form-group.optional label::after {
    content: ' (' attr(data-optional-text) ')';
    color: var(--text-muted);
    font-weight: normal;
    font-size: 0.85em;
}

.api-key-form .form-group.optional .form-input,
.api-key-form .form-group.optional .form-select,
.api-key-form .form-group.optional .form-textarea {
    border-color: var(--border-color);
    opacity: 0.85;
}

.api-key-form .form-group.optional .form-input:focus,
.api-key-form .form-group.optional .form-select:focus,
.api-key-form .form-group.optional .form-textarea:focus {
    opacity: 1;
    border-color: var(--accent-cyan);
}

.api-key-form .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* API Key 建立成功區 */
.api-key-created-section {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 1.5rem;
    margin-top: 1rem;
    border: 2px solid var(--accent-yellow);
}

.api-key-created-alert {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.api-key-created-alert .alert-icon {
    font-size: 2rem;
}

.api-key-created-alert .alert-content h4 {
    margin: 0 0 0.5rem 0;
    color: var(--accent-yellow);
}

.api-key-created-alert .alert-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.api-key-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.api-key-display code {
    flex: 1;
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--accent-cyan);
    word-break: break-all;
}

.api-key-display .copy-btn {
    flex-shrink: 0;
}

.api-key-created-section > .btn {
    width: 100%;
}

/* 刪除確認 */
.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #dc2626;
}

/* 響應式調整 */
@media (max-width: 500px) {
    .settings-language-select {
        grid-template-columns: repeat(2, 1fr);
    }

    .settings-theme-toggle {
        flex-direction: column;
    }
}

/* 獎盃彈窗 */
.trophy-modal {
    max-width: 900px;
}

.trophy-description {
    text-align: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.1), rgba(255, 152, 0, 0.1));
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

/* 雙獎杯顯示區 */
.trophy-dual-display {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 1.5rem;
}

.trophy-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 2rem;
    border-radius: 16px;
    min-width: 160px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.trophy-item:hover {
    transform: translateY(-4px);
}

/* 金色獎杯樣式 */
.trophy-gold {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.15), rgba(255, 152, 0, 0.15));
    border: 2px solid rgba(255, 193, 7, 0.4);
    box-shadow: 0 4px 20px rgba(255, 193, 7, 0.2);
}

.trophy-gold:hover {
    box-shadow: 0 8px 30px rgba(255, 193, 7, 0.35);
}

.trophy-gold .trophy-icon {
    font-size: 3rem;
    filter: drop-shadow(0 4px 8px rgba(255, 193, 7, 0.5));
    margin-bottom: 0.5rem;
}

.trophy-gold .trophy-number {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ffc107, #ff9800);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 15px rgba(255, 193, 7, 0.5));
}

/* 銀色獎杯樣式 */
.trophy-silver {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.15), rgba(169, 169, 169, 0.15));
    border: 2px solid rgba(192, 192, 192, 0.4);
    box-shadow: 0 4px 20px rgba(192, 192, 192, 0.2);
}

.trophy-silver:hover {
    box-shadow: 0 8px 30px rgba(192, 192, 192, 0.35);
}

.trophy-silver .trophy-icon {
    font-size: 3rem;
    filter: drop-shadow(0 4px 8px rgba(192, 192, 192, 0.5));
    margin-bottom: 0.5rem;
}

.trophy-silver .trophy-number {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #e8e8e8, #a8a8a8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 15px rgba(192, 192, 192, 0.5));
}

.trophy-item-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 0.3rem;
}

.trophy-main-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.trophy-big-number {
    font-size: 4rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ffc107, #ff9800);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 20px rgba(255, 193, 7, 0.5));
}

.trophy-label {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.trophy-capability {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.trophy-capability .highlight-number {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffc107;
    text-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

.trophy-sub-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
}

.trophy-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    max-height: 250px;
    overflow-y: auto;
}

.trophy-category-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.trophy-category-tag:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.2);
    transform: scale(1.05);
}

.trophy-category-tag.critical {
    border-color: var(--risk-critical);
    background: rgba(239, 68, 68, 0.1);
}

.trophy-category-tag.high {
    border-color: var(--risk-high);
    background: rgba(249, 115, 22, 0.1);
}

.trophy-category-tag.medium {
    border-color: var(--risk-medium);
    background: rgba(234, 179, 8, 0.1);
}

.trophy-category-tag.low {
    border-color: var(--risk-low);
    background: rgba(34, 197, 94, 0.1);
}

.trophy-category-tag .risk-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.trophy-category-tag .risk-dot.critical { background: var(--risk-critical); }
.trophy-category-tag .risk-dot.high { background: var(--risk-high); }
.trophy-category-tag .risk-dot.medium { background: var(--risk-medium); }
.trophy-category-tag .risk-dot.low { background: var(--risk-low); }

/* 獎盃彈窗 - 觸發次數標籤 */
.trophy-category-count {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 4px;
    padding: 1px 5px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

/* 獎盃彈窗 - 風險等級區塊 */
.trophy-level-section {
    margin-bottom: 1rem;
}

.trophy-level-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border-color);
}

.trophy-level-name {
    font-weight: 600;
    color: var(--text-primary);
}

.trophy-level-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.trophy-level-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* 獎盃彈窗 - 統計摘要 */
.trophy-summary {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.trophy-summary-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
}

.trophy-summary-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.trophy-stat {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.trophy-stat .risk-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* 獎盃彈窗 - 載入狀態 */
.trophy-loading,
.trophy-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* ==================== 數字變化動畫 ==================== */
@keyframes numberPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); color: var(--accent-cyan); }
    100% { transform: scale(1); }
}

.number-changed {
    animation: numberPop 0.4s ease-out;
}

/* ==================== 知識中心按鈕 ==================== */
.knowledge-center-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 1rem;
}

.knowledge-center-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-cyan);
    color: var(--text-primary);
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.2);
}

.knowledge-center-btn .kc-icon {
    font-size: 1.2rem;
}

.knowledge-center-btn .kc-text {
    font-weight: 600;
}

/* ==================== 知識中心書本模態框 ==================== */
.knowledge-modal {
    max-width: 1100px;
    width: 95%;
    height: 85vh;
    display: flex;
    flex-direction: column;
}

.knowledge-modal .modal-body {
    flex: 1;
    display: flex;
    padding: 0;
    overflow: hidden;
}

/* 書本容器 */
.book-container {
    display: flex;
    width: 100%;
    height: 100%;
    background: var(--bg-card);
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

/* 左側目錄 */
.book-toc {
    width: 280px;
    min-width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.toc-header {
    padding: 1rem 1.2rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(99, 102, 241, 0.15));
    border-bottom: 1px solid var(--border-color);
}

.toc-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #a78bfa;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toc-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

/* 目錄章節 */
.toc-chapter {
    margin-bottom: 0.25rem;
}

.toc-chapter-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.toc-chapter-title:hover {
    background: var(--bg-card);
    border-left-color: var(--accent-purple);
}

.toc-chapter-title.active {
    background: rgba(139, 92, 246, 0.1);
    border-left-color: var(--accent-purple);
    color: #a78bfa;
}

.toc-chapter-title .chapter-icon {
    margin-right: 0.5rem;
}

.toc-chapter-title .expand-icon {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.toc-chapter-title.expanded .expand-icon {
    transform: rotate(90deg);
}

/* 目錄子項目 */
.toc-sections {
    display: none;
    padding-left: 1rem;
}

.toc-sections.show {
    display: block;
}

.toc-section {
    display: block;
    padding: 0.5rem 1.2rem 0.5rem 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
    text-decoration: none;
}

.toc-section:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-left-color: var(--accent-cyan);
}

.toc-section.active {
    background: rgba(0, 217, 255, 0.1);
    color: var(--accent-cyan);
    border-left-color: var(--accent-cyan);
    font-weight: 500;
}

/* 右側內容區 */
.book-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    overflow-x: auto;
    background: var(--bg-card);
}

.book-content h1 {
    font-size: 1.8rem;
    color: var(--text-primary);
    margin: 0 0 1.5rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--accent-purple);
}

.book-content h2 {
    font-size: 1.3rem;
    color: #a78bfa;
    margin: 2rem 0 1rem 0;
}

.book-content h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 1.5rem 0 0.75rem 0;
}

.book-content p {
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.book-content ul, .book-content ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.book-content li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

/* 程式碼區塊 */
.book-content pre {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.book-content code {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--accent-cyan);
}

.book-content pre code {
    color: var(--text-secondary);
}

/* 程式碼標籤列 */
.code-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: -1px;
}

.code-tab {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.code-tab:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.code-tab.active {
    background: var(--bg-primary);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
    border-bottom: 1px solid var(--bg-primary);
}

.code-panel {
    display: none;
}

.code-panel.active {
    display: block;
}

/* 提示框 */
.book-content .info-box {
    background: rgba(0, 217, 255, 0.1);
    border: 1px solid var(--accent-cyan);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.book-content .info-box.warning {
    background: rgba(249, 115, 22, 0.1);
    border-color: var(--risk-high);
}

.book-content .info-box-title {
    font-weight: 600;
    color: var(--accent-cyan);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.book-content .info-box.warning .info-box-title {
    color: var(--risk-high);
}

/* API 表格樣式 */
.book-content .api-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.book-content .api-table th,
.book-content .api-table td {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.book-content .api-table th {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
}

.book-content .api-table td {
    background: var(--bg-card);
    color: var(--text-secondary);
}

.book-content .api-table td:nth-child(1) {
    white-space: nowrap;
    font-weight: 500;
}

.book-content .api-table td:nth-child(2) {
    white-space: nowrap;
    color: var(--accent-cyan);
    min-width: 80px;
}

.book-content .api-table td:last-child {
    min-width: 200px;
}

.book-content .api-table tr:hover td {
    background: var(--bg-secondary);
}

/* ENT 專屬標示樣式 */
.book-content .ent-badge {
    display: inline-block;
    background: linear-gradient(135deg, #8b5cf6, #a855f7);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.book-content h2 .ent-badge {
    font-size: 0.65rem;
}

.book-content .ent-line {
    color: #a855f7;
}

.book-content pre .ent-field {
    color: #a855f7;
}

/* 程式碼複製按鈕樣式 */
.book-content .code-panel {
    position: relative;
}

.book-content .code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: rgba(0, 217, 255, 0.15);
    border: 1px solid rgba(0, 217, 255, 0.3);
    border-radius: 4px;
    color: var(--accent-cyan);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    z-index: 10;
}

.book-content .code-copy-btn:hover {
    background: rgba(0, 217, 255, 0.25);
    border-color: var(--accent-cyan);
    transform: translateY(-1px);
}

.book-content .code-copy-btn:active {
    transform: translateY(0);
}

.book-content .code-copy-btn.copied {
    background: rgba(16, 185, 129, 0.2);
    border-color: #10b981;
    color: #10b981;
}

/* 複製提示 Toast (2秒淡出) */
.code-copy-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.8rem 1.5rem;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.code-copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 流程圖美化樣式 */
.book-content .flow-diagram {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin: 1rem 0;
    min-width: fit-content;
    overflow-x: auto;
}

.book-content .flow-node {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 200px;
    text-align: center;
}

.book-content .flow-node.start {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: white;
    border-radius: 24px;
}

.book-content .flow-node.decision {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    transform: rotate(0deg);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    padding: 1.5rem 2rem;
    min-width: 180px;
}

.book-content .flow-node.action {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}

.book-content .flow-node.action.pass {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.book-content .flow-node.action.filter {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

.book-content .flow-node.action.block {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.book-content .flow-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.book-content .flow-arrow-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

.book-content .flow-branch {
    display: flex;
    justify-content: center;
    gap: 2rem;
    width: 100%;
    flex-wrap: nowrap;
    min-width: fit-content;
}

.book-content .flow-branch-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .knowledge-modal {
        width: 100%;
        height: 100vh;
        max-width: none;
        border-radius: 0;
    }

    .book-container {
        flex-direction: column;
    }

    .book-toc {
        width: 100%;
        min-width: auto;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .book-content {
        padding: 1rem;
    }

    .knowledge-center-btn .kc-text {
        display: none;
    }

    .knowledge-center-btn {
        padding: 0.5rem;
    }
}

/* ==================== 資料來源切換 Tab ==================== */
.data-source-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.data-source-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.data-source-tab:hover {
    color: var(--text-primary);
    background: var(--bg-card);
    border-color: var(--accent-cyan);
}

.data-source-tab.active {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: white;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.4);
}

.data-source-tab .tab-icon {
    font-size: 1rem;
}

.data-source-tab .tab-label {
    font-weight: 600;
}

/* ==================== 時間區間選擇器 ==================== */
.time-range-selector {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-secondary);
    padding: 0.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.time-range-btn {
    padding: 0.4rem 0.8rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.75rem;
    white-space: nowrap;
}

.time-range-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.time-range-btn.active {
    background: var(--accent-purple);
    color: white;
    font-weight: 600;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

/* 即時訊息開關 */
.realtime-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.realtime-toggle .toggle-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: 0.3s;
    border-radius: 20px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent-purple);
    border-color: var(--accent-purple);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(16px);
    background-color: white;
}

/* 自訂日期選擇器 */
.custom-date-picker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.5rem;
    padding: 0.3rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.date-input {
    padding: 0.3rem 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.75rem;
    width: 120px;
}

.date-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 5px rgba(0, 217, 255, 0.3);
}

.date-separator {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.date-apply-btn {
    padding: 0.3rem 0.6rem;
    background: var(--accent-cyan);
    border: none;
    border-radius: 6px;
    color: var(--bg-dark);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.date-apply-btn:hover {
    background: var(--accent-purple);
    color: white;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

/* ==================== ImportData 模式容器 ==================== */
.import-mode-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.show-data-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

.show-data-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.6);
}

.show-data-btn .btn-icon {
    font-size: 1rem;
}

/* ==================== 匯入資料彈窗 ==================== */
.import-data-modal {
    max-width: 650px;
}

.import-step {
    margin-bottom: 1.5rem;
    padding: 1.2rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: white;
    font-weight: 700;
    font-size: 1rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.step-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.step-content {
    padding-left: 2.5rem;
}

.step-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.download-template-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-template-btn:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.3);
}

/* 上傳區域 */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 1rem;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent-cyan);
    background: rgba(0, 217, 255, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.upload-text {
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
}

.upload-formats {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* 已選檔案列表 */
.selected-files {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.files-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.clear-files-btn {
    padding: 0.3rem 0.6rem;
    background: transparent;
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-files-btn:hover {
    border-color: var(--risk-critical);
    color: var(--risk-critical);
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 0.85rem;
}

.file-item .file-icon {
    font-size: 1.2rem;
}

.file-item .file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item .file-size {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.file-item .remove-file-btn {
    padding: 0.2rem 0.4rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s ease;
}

.file-item .remove-file-btn:hover {
    color: var(--risk-critical);
}

/* 額度資訊 */
.quota-info {
    margin-bottom: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(59, 130, 246, 0.1));
    border-radius: 10px;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.quota-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

.quota-icon {
    font-size: 1.1rem;
}

.quota-title {
    font-weight: 600;
    color: var(--text-primary);
}

.quota-items {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
}

.quota-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.6rem;
    background: var(--bg-card);
    border-radius: 8px;
    text-align: center;
}

.quota-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.quota-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.quota-limit {
    color: var(--accent-cyan);
}

/* 序號輸入 */
.serial-input-section {
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.serial-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
}

.serial-input-row {
    display: flex;
    gap: 0.5rem;
}

.serial-input {
    flex: 1;
    padding: 0.6rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.serial-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 5px rgba(0, 217, 255, 0.3);
}

.serial-submit-btn {
    padding: 0.6rem 1.2rem;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    border: none;
    border-radius: 6px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.serial-submit-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.5);
}

/* 開始匯入按鈕禁用狀態 */
#startImportBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#startImportBtn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .data-source-tabs {
        flex-wrap: wrap;
    }

    .time-range-selector {
        flex-wrap: wrap;
        justify-content: center;
    }

    .mode-switch-container {
        flex-direction: column;
        gap: 1rem;
    }

    .quota-items {
        grid-template-columns: 1fr;
    }

    .import-data-modal {
        max-width: 95%;
    }
}

/* ==================== 對話詳情彈窗 ==================== */
.conversation-detail-modal {
    max-width: 700px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.8rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.detail-content-section {
    margin-bottom: 1rem;
}

.detail-content-header {
    margin-bottom: 0.5rem;
}

.detail-content-box {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}

.detail-content-box.filtered {
    background: rgba(0, 217, 255, 0.1);
    border-color: var(--accent-cyan);
}

/* 用戶資訊區塊樣式 */
.detail-user-info-box {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px;
}

.user-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 120px;
}

.user-info-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-info-value {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-all;
}

.user-info-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    width: fit-content;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

/* Reply To 區塊樣式 */
.detail-reply-to-box {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.reply-to-id-badge {
    display: inline-block;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    width: fit-content;
}

.detail-content-box.reply-to {
    background: rgba(99, 102, 241, 0.1);
    border-color: #6366f1;
    border-left: 3px solid #6366f1;
    font-style: italic;
    color: var(--text-secondary);
}

/* Knowledge 區塊樣式 */
.detail-content-box.knowledge {
    background: rgba(34, 197, 94, 0.1);
    border-color: #22c55e;
    max-height: 300px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.85rem;
}

/* 表格行可點擊樣式 */
.conversation-table tbody tr {
    cursor: pointer;
    transition: all 0.2s ease;
}

.conversation-table tbody tr:hover {
    background: rgba(0, 217, 255, 0.1);
}

.conversation-table tbody tr:active {
    background: rgba(0, 217, 255, 0.2);
}

/* 風險等級 badge 樣式 */
.detail-value.risk-critical {
    color: var(--risk-critical);
}

.detail-value.risk-high {
    color: var(--risk-high);
}

.detail-value.risk-medium {
    color: var(--risk-medium);
}

.detail-value.risk-low {
    color: var(--risk-low);
}

@media (max-width: 768px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .conversation-detail-modal {
        max-width: 95%;
    }
}

/* ==================== 載入進度條樣式（切換專案時顯示） ==================== */

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.loading-screen.show {
    opacity: 1;
    pointer-events: all;
}

/* 霧化背景 */
.loading-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.3);
}

/* 進度條容器 */
.loading-bar-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 600px;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px 32px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

/* 進度條 */
.loading-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.loading-bar-fill {
    height: 100%;
    background: linear-gradient(90deg,
        var(--accent-cyan),
        var(--accent-purple),
        var(--accent-cyan)
    );
    background-size: 200% 100%;
    border-radius: 10px;
    width: 0%;
    transition: width 0.3s ease-out;
    animation: shimmer 2s linear infinite;
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.5);
}

/* 文字顯示 */
.loading-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--text-secondary);
}

#loadingStatus {
    font-weight: 500;
}

#loadingPercentage {
    font-weight: 700;
    color: var(--accent-cyan);
    font-size: 16px;
}

/* 跑馬燈動畫 */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* 完成動畫 */
.loading-bar-fill.complete {
    animation: shimmer 2s linear infinite, pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0%, 100% {
        transform: scaleY(1);
    }
    50% {
        transform: scaleY(1.2);
    }
}

/* 響應式設計 */
@media (max-width: 768px) {
    .loading-logo-text {
        font-size: 36px;
        letter-spacing: 4px;
    }
    
    .loading-subtitle {
        font-size: 14px;
    }
    
    .loading-percentage {
        font-size: 20px;
    }
}

/* ==================== 表格風險類別群組樣式 ==================== */
.table-category-groups {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 200px;
}

.table-category-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.table-group-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s ease;
    user-select: none;
}

.table-group-header:hover {
    filter: brightness(1.1);
}

.table-group-header.risk-critical {
    background: rgba(220, 53, 69, 0.15);
    color: #ff6b7a;
    border: 1px solid rgba(220, 53, 69, 0.3);
}

.table-group-header.risk-high {
    background: rgba(255, 152, 0, 0.15);
    color: #ffb347;
    border: 1px solid rgba(255, 152, 0, 0.3);
}

.table-group-header.risk-medium {
    background: rgba(255, 235, 59, 0.15);
    color: #ffd54f;
    border: 1px solid rgba(255, 235, 59, 0.3);
}

.table-group-header.risk-low {
    background: rgba(76, 175, 80, 0.15);
    color: #81c784;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.table-group-header.risk-safe {
    background: rgba(96, 125, 139, 0.15);
    color: #90a4ae;
    border: 1px solid rgba(96, 125, 139, 0.3);
}

.table-group-toggle {
    font-size: 8px;
    width: 10px;
    text-align: center;
    transition: transform 0.2s ease;
}

.table-group-name {
    flex: 1;
}

.table-group-items {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    padding-left: 14px;
    margin-top: 2px;
}

.table-group-items .risk-badge {
    font-size: 10px;
    padding: 1px 5px;
}

/* 無風險類別時的顯示 */
.table-category-groups .risk-badge.safe {
    font-size: 10px;
    padding: 2px 6px;
}
