/* ============== Base & Reset ============== */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Brand Colors */
    --primary: #f05d22;
    --primary-light: #ff8a50;
    --primary-dark: #c73100;
    --secondary: #231F20;
    --secondary-light: #484446;

    /* Background Colors */
    --bg-default: #f5f5f5;
    --bg-paper: #ffffff;

    /* Text Colors */
    --text-primary: #231F20;
    --text-secondary: #666666;
    --text-disabled: #9e9e9e;

    /* Status Colors */
    --success: #4CAF50;
    --error: #f44336;
    --warning: #ff9800;
    --info: #2196F3;

    /* Entity Colors */
    --entity-person: #f05d22;
    --entity-organization: #231F20;
    --entity-country: #2196F3;
    --entity-location: #4CAF50;
    --entity-event: #9C27B0;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-brand: 0 2px 8px rgba(240,93,34,0.3);

    /* Spacing */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

body {
    font-family: 'Montserrat', 'Noto Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-default);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============== Layout ============== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* ============== Header ============== */
header {
    background-color: var(--secondary);
    padding: 20px 0;
    margin: -24px -24px 32px -24px;
    width: calc(100% + 48px);
}

header .header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.logo {
    font-size: 28px;
    font-weight: 700;
    color: white;
}

.logo-accent {
    color: var(--primary);
}

.tagline {
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    margin-top: 6px;
}

/* File Switcher */
.file-switcher {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-switcher label {
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    font-weight: 500;
}

.file-switcher select {
    padding: 10px 16px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    min-width: 280px;
    transition: all 0.2s;
}

.file-switcher select:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
}

.file-switcher select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-brand);
}

.file-switcher select option {
    background: var(--secondary);
    color: white;
}

/* ============== Loading ============== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    color: var(--primary);
    font-size: 18px;
    font-weight: 500;
}

/* ============== Stats Grid ============== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-paper);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    margin-top: 8px;
}

/* ============== Stats Grid Simple ============== */
.stats-grid-simple {
    grid-template-columns: repeat(2, 1fr);
    max-width: 400px;
    margin-left: auto;
    gap: 12px;
}

.stats-grid-simple .stat-card {
    background: #fff;
    border: 1px solid #eee;
    border-top: 3px solid var(--primary);
    padding: 16px 20px;
}

.stats-grid-simple .stat-card:hover {
    border-color: #ddd;
    border-top-color: var(--primary);
    transform: none;
}

.stats-grid-simple .stat-value {
    font-size: 28px;
}

.stats-grid-simple .stat-label {
    font-size: 12px;
}

/* ============== Filters Panel ============== */
.filters-panel {
    background: var(--bg-paper);
    border-radius: var(--radius-lg);
    margin-bottom: 32px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid #eee;
}

/* Simplified Filter Panel */
.filters-panel-simple {
    padding: 24px;
}

.filters-panel-simple .search-section {
    margin-bottom: 20px;
}

.filters-panel-simple .search-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filters-panel-simple .filter-search-input {
    flex: 1;
    padding-right: 44px;
}

.filters-panel-simple .search-btn {
    padding: 12px 24px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
}

.filters-panel-simple .search-btn:hover {
    background: var(--primary-dark);
}

.entity-tags-section {
    border-top: 1px solid #eee;
    padding-top: 20px;
    margin-top: 20px;
}

.entity-tags-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.entity-tags-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.clear-entity-btn {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.clear-entity-btn:hover {
    border-color: var(--error);
    color: var(--error);
}

.filter-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
}

.filter-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
}

.filter-icon {
    color: var(--text-secondary);
}

.filter-badge {
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.clear-filters-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid #e0e0e0;
    border-radius: var(--radius-md);
    background: var(--bg-paper);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.clear-filters-btn:hover {
    border-color: var(--error);
    color: var(--error);
    background: rgba(244, 67, 54, 0.05);
}

.filter-divider {
    height: 1px;
    background: #e8e8e8;
}

/* Filter Accordion */
.filter-accordion {
    border-bottom: 1px solid #f0f0f0;
}

.filter-accordion:last-of-type {
    border-bottom: none;
}

.filter-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.filter-accordion-header:hover {
    background: var(--bg-default);
}

.filter-accordion-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.filter-accordion-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-chip {
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.filter-accordion-icon {
    color: var(--text-disabled);
    transition: transform 0.3s;
}

.filter-accordion.expanded .filter-accordion-icon {
    transform: rotate(180deg);
}

.filter-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.filter-accordion.expanded .filter-accordion-content {
    max-height: 400px;
}

.filter-accordion-body {
    padding: 0 20px 16px;
}

/* Search Input */
.search-input-wrapper {
    position: relative;
}

.search-input-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-disabled);
    pointer-events: none;
}

.filter-search-input {
    width: 100%;
    padding: 12px 16px;
    padding-right: 44px;
    border: 1px solid #e0e0e0;
    border-radius: var(--radius-md);
    background: var(--bg-default);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
}

.filter-search-input::placeholder {
    color: var(--text-disabled);
}

.filter-search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-paper);
    box-shadow: 0 0 0 3px rgba(240,93,34,0.1);
}

/* Filter Chips Group */
.filter-chips-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.filter-chip-toggle {
    position: relative;
    cursor: pointer;
}

.filter-chip-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.filter-chip-label {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-default);
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.filter-chip-label:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-chip-toggle input:checked + .filter-chip-label {
    background: rgba(240, 93, 34, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.filter-chip-label.warning:hover,
.filter-chip-toggle input:checked + .filter-chip-label.warning {
    background: rgba(255, 152, 0, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}

.filter-chip-label.muted:hover,
.filter-chip-toggle input:checked + .filter-chip-label.muted {
    background: rgba(158, 158, 158, 0.1);
    border-color: #9e9e9e;
    color: #757575;
}

/* Entity Quick Tags */
.entity-quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.entity-tags-loading {
    color: var(--text-disabled);
    font-size: 13px;
    font-style: italic;
}

.entity-quick-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.entity-quick-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
}

.entity-quick-tag.selected {
    box-shadow: 0 0 0 2px var(--primary);
}

.entity-quick-tag .tag-icon {
    font-size: 13px;
    display: inline-flex;
    align-items: center;
}

.entity-quick-tag .tag-icon svg {
    width: 14px;
    height: 14px;
}

.entity-quick-tag .tag-count {
    display: none;
}

/* Entity type colors for quick tags */
.entity-quick-tag.entity-person {
    background: rgba(240, 93, 34, 0.1);
    color: #d84315;
    border: 1px solid rgba(240, 93, 34, 0.3);
}

.entity-quick-tag.entity-organization {
    background: rgba(63, 81, 181, 0.1);
    color: #303f9f;
    border: 1px solid rgba(63, 81, 181, 0.3);
}

.entity-quick-tag.entity-location {
    background: rgba(76, 175, 80, 0.1);
    color: #2e7d32;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.entity-quick-tag.entity-country {
    background: rgba(33, 150, 243, 0.1);
    color: #1565c0;
    border: 1px solid rgba(33, 150, 243, 0.3);
}

.entity-quick-tag.entity-event {
    background: rgba(156, 39, 176, 0.1);
    color: #7b1fa2;
    border: 1px solid rgba(156, 39, 176, 0.3);
}

/* Filter Actions */
.filter-actions {
    padding: 16px 20px;
    background: var(--bg-default);
    border-top: 1px solid #e8e8e8;
}

.apply-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.apply-btn:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-brand);
}

.apply-btn svg {
    flex-shrink: 0;
}

/* ============== Section Title ============== */
.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ============== Clusters Grid ============== */
.clusters-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

@media (max-width: 1000px) {
    .clusters-grid {
        grid-template-columns: 1fr;
    }
}

.cluster-card {
    background: var(--bg-paper);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    border: 1px solid #e0e0e0;
    border-right: 3px solid var(--primary);
    overflow: hidden;
}

.cluster-card:hover {
    box-shadow: 0 6px 24px rgba(240, 93, 34, 0.15);
    border-color: #ddd;
    border-right-color: var(--primary);
}

.cluster-card .card-content {
    padding: 24px;
    flex: 1;
}

.cluster-card .card-footer {
    padding: 14px 24px;
    background: #f8f8f8;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
}

.cluster-card .card-entities {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.cluster-card .news-count {
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    background: rgba(240, 93, 34, 0.08);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(240, 93, 34, 0.2);
}

.cluster-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    line-height: 1.6;
    color: var(--text-primary);
}

.cluster-summary {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.8;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Legacy support */
.cluster-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.item-count {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

/* ============== Badges ============== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
}

.badge-merged {
    background: rgba(158, 158, 158, 0.15);
    color: #757575;
}

.badge-review {
    background: rgba(255, 152, 0, 0.15);
    color: #f57c00;
}

.badge-outlier {
    background: rgba(244, 67, 54, 0.15);
    color: var(--error);
}

.badge-opinion {
    background: rgba(156, 39, 176, 0.15);
    color: #9C27B0;
}

.badge-fact {
    background: rgba(33, 150, 243, 0.15);
    color: var(--info);
}

.badges-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

/* ============== Quality Badge ============== */
.quality-badge {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
}

.quality-high {
    background: rgba(76, 175, 80, 0.15);
    color: var(--success);
}

.quality-medium {
    background: rgba(255, 152, 0, 0.15);
    color: var(--warning);
}

.quality-low {
    background: rgba(244, 67, 54, 0.15);
    color: var(--error);
}

/* ============== Sub-cluster Indicator ============== */
.sub-cluster-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    background: rgba(156, 39, 176, 0.12);
    color: #7B1FA2;
}

.sub-cluster-indicator svg {
    width: 14px;
    height: 14px;
}

/* ============== Entity Badges ============== */
.entity-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.entity-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

.entity-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.entity-badge .entity-icon {
    font-size: 11px;
    display: inline-flex;
    align-items: center;
}

.entity-badge .entity-icon svg {
    width: 11px;
    height: 11px;
}

/* Entity type colors */
.entity-person {
    background: rgba(240, 93, 34, 0.12);
    color: #d84315;
    border: 1px solid rgba(240, 93, 34, 0.25);
}

.entity-organization {
    background: rgba(63, 81, 181, 0.12);
    color: #303f9f;
    border: 1px solid rgba(63, 81, 181, 0.25);
}

.entity-location {
    background: rgba(76, 175, 80, 0.12);
    color: #2e7d32;
    border: 1px solid rgba(76, 175, 80, 0.25);
}

.entity-country {
    background: rgba(33, 150, 243, 0.12);
    color: #1565c0;
    border: 1px solid rgba(33, 150, 243, 0.25);
}

.entity-event {
    background: rgba(156, 39, 176, 0.12);
    color: #7b1fa2;
    border: 1px solid rgba(156, 39, 176, 0.25);
}

/* ============== Opinion Indicators ============== */
.opinion-indicators {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.indicator {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
}

.indicator-support {
    background: rgba(76, 175, 80, 0.12);
    color: var(--success);
}

.indicator-dispute {
    background: rgba(244, 67, 54, 0.12);
    color: var(--error);
}

.merged-info {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-disabled);
}

/* ============== Loading More ============== */
.loading-more {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 32px;
    color: var(--text-secondary);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(240, 93, 34, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.end-message {
    text-align: center;
    padding: 32px;
    color: var(--text-disabled);
    font-size: 14px;
}

/* ============== Bullet Lists ============== */
.bullet-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.bullet-list li {
    position: relative;
    padding-right: 20px;
    margin-bottom: 10px;
    line-height: 1.8;
}

.bullet-list li:before {
    content: "•";
    position: absolute;
    right: 0;
    color: var(--primary);
    font-weight: bold;
}

/* ============== Cluster Detail Page ============== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 24px;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary);
}

.cluster-detail-header {
    background: var(--bg-paper);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.cluster-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.cluster-detail-header .cluster-id {
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    font-family: 'Monaco', 'Consolas', monospace;
}

.cluster-count {
    background: var(--bg-default);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
}

.cluster-detail-header .badge {
    padding: 8px 14px;
    font-size: 12px;
}

.cluster-detail-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
    line-height: 1.4;
    color: var(--text-primary);
}

.cluster-detail-summary {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.8;
}

/* ============== Similarity Badges ============== */
.item-similarity {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    font-family: 'Monaco', 'Consolas', monospace;
}

.sim-high {
    background: rgba(76, 175, 80, 0.15);
    color: var(--success);
}

.sim-medium {
    background: rgba(255, 152, 0, 0.15);
    color: var(--warning);
}

.sim-low {
    background: rgba(244, 67, 54, 0.15);
    color: var(--error);
}

/* ============== Opinions Section ============== */
.opinions-section {
    margin-top: 24px;
}

.opinions-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.opinion-card {
    background: var(--bg-paper);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.opinion-card.supporting {
    border-top: 4px solid var(--success);
}

.opinion-card.disputing {
    border-top: 4px solid var(--error);
}

.opinion-card-header {
    padding: 16px 20px;
    font-weight: 600;
    font-size: 14px;
}

.opinion-card-header.supporting {
    background: rgba(76, 175, 80, 0.08);
    color: var(--success);
}

.opinion-card-header.disputing {
    background: rgba(244, 67, 54, 0.08);
    color: var(--error);
}

.opinion-card-content {
    padding: 20px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-secondary);
}

.no-opinions {
    color: var(--text-disabled);
    font-style: italic;
}

/* ============== Items Section ============== */
.items-section {
    margin-top: 24px;
}

.item-card {
    background: var(--bg-paper);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid #eee;
    transition: all 0.2s;
}

.item-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #ddd;
}

.item-card.outlier {
    border-color: rgba(244, 67, 54, 0.3);
    background: rgba(244, 67, 54, 0.02);
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.item-id {
    color: var(--text-disabled);
    font-size: 12px;
    font-family: 'Monaco', 'Consolas', monospace;
}

.badges {
    display: flex;
    gap: 8px;
    align-items: center;
}

.outlier-reason {
    font-size: 11px;
    color: var(--error);
    margin-right: 8px;
}

.item-text {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-primary);
}

.item-meta {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-disabled);
    display: flex;
    gap: 16px;
}

/* ============== Sub-cluster Tag on Items ============== */
.item-sub-cluster-tag {
    margin-bottom: 10px;
}

.sub-cluster-tag {
    display: inline-block;
    padding: 6px 12px;
    background: rgba(156, 39, 176, 0.08);
    border: 1px solid rgba(156, 39, 176, 0.2);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: #7B1FA2;
    font-weight: 500;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============== Entities Section ============== */
.entities-section {
    margin-top: 24px;
}

.entities-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.entity-group {
    background: var(--bg-paper);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid #eee;
}

.entity-group-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.entity-group-title svg {
    width: 16px;
    height: 16px;
}

.entity-group-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.entity-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-default);
    border-radius: var(--radius-md);
    transition: background 0.2s;
}

.entity-item:hover {
    background: #ebebeb;
}

.entity-item-name {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

.entity-item-count {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-paper);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* ============== Sub-clusters Section ============== */
.sub-clusters-section {
    margin-top: 24px;
}

/* ============== Accordion ============== */
.accordion-item {
    background: var(--bg-paper);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid #eee;
}

.accordion-header {
    padding: 18px 24px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
    user-select: none;
}

.accordion-header:hover {
    background: var(--bg-default);
}

.accordion-header .accordion-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.accordion-header .accordion-meta {
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.accordion-header .accordion-icon {
    font-size: 14px;
    transition: transform 0.3s;
    color: var(--text-disabled);
}

.accordion-item.expanded .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.accordion-item.expanded .accordion-content {
    max-height: 5000px;
}

.accordion-body {
    padding: 0 24px 24px;
}

/* ============== Sub-cluster Card ============== */
.sub-cluster-card {
    background: var(--bg-default);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 14px;
    border: 1px solid #e8e8e8;
    transition: all 0.2s;
}

.sub-cluster-card:hover {
    border-color: #ddd;
    box-shadow: var(--shadow-sm);
}

.sub-cluster-card:last-child {
    margin-bottom: 0;
}

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

.sub-cluster-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    line-height: 1.4;
}

.sub-cluster-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.sub-cluster-count {
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-paper);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.sub-cluster-summary {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 12px;
}

.sub-cluster-entities {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.sub-cluster-items-toggle {
    padding: 10px 18px;
    background: var(--bg-paper);
    border: 1px solid #ddd;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.sub-cluster-items-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(240, 93, 34, 0.04);
}

.sub-cluster-items {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e8e8e8;
    display: none;
}

.sub-cluster-items.expanded {
    display: block;
}

/* ============== Level Labels ============== */
.level-label {
    font-size: 10px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.level-primary {
    background: rgba(33, 150, 243, 0.12);
    color: var(--info);
}

.level-secondary {
    background: rgba(156, 39, 176, 0.12);
    color: #9C27B0;
}

.level-tertiary {
    background: rgba(255, 152, 0, 0.12);
    color: var(--warning);
}

/* ============== Orphan Items Section ============== */
.orphan-items-section {
    margin-top: 24px;
    padding: 24px;
    background: rgba(244, 67, 54, 0.03);
    border: 1px solid rgba(244, 67, 54, 0.15);
    border-radius: var(--radius-lg);
}

.orphan-items-section .section-title {
    color: var(--error);
}

/* ============== Custom Scrollbar ============== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* ============== Entity Detail Page ============== */
.entity-detail-header {
    background: var(--bg-paper);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.entity-meta {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.entity-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
}

.entity-type-badge svg {
    width: 16px;
    height: 16px;
}

.entity-type-badge.entity-person {
    background: rgba(240, 93, 34, 0.15);
    color: var(--entity-person);
}

.entity-type-badge.entity-organization {
    background: rgba(35, 31, 32, 0.12);
    color: var(--entity-organization);
}

.entity-type-badge.entity-location,
.entity-type-badge.entity-country {
    background: rgba(76, 175, 80, 0.15);
    color: var(--entity-location);
}

.entity-type-badge.entity-event {
    background: rgba(156, 39, 176, 0.15);
    color: var(--entity-event);
}

.entity-stats {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.entity-detail-name {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.4;
    color: var(--text-primary);
}

.entity-detail-name-en {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Associated Entities */
.associated-entities-section {
    margin-bottom: 24px;
}

.associated-entities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.associated-entity-group {
    background: var(--bg-paper);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid #eee;
}

.associated-entity-group-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.associated-entity-group-title svg {
    width: 16px;
    height: 16px;
}

.associated-entity-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.associated-entity-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-default);
    border-radius: var(--radius-md);
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.associated-entity-item:hover {
    background: #ebebeb;
    transform: translateX(-4px);
}

.associated-entity-name {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

.associated-entity-count {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-paper);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* Entity Items Section */
.entity-items-section {
    margin-top: 24px;
}

.entity-clusters-section {
    margin-bottom: 24px;
}

/* Entity Item Card with cluster link */
.entity-item-card {
    background: var(--bg-paper);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid #eee;
    transition: all 0.2s;
}

.entity-item-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #ddd;
}

.entity-item-cluster-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(240, 93, 34, 0.08);
    border: 1px solid rgba(240, 93, 34, 0.2);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.entity-item-cluster-link:hover {
    background: rgba(240, 93, 34, 0.15);
    transform: translateX(-4px);
}

/* Load More Button */
.load-more-btn {
    display: block;
    width: 100%;
    padding: 16px 24px;
    margin-top: 20px;
    background: var(--bg-paper);
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    color: var(--primary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.load-more-btn:hover {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-brand);
}

/* Clickable Entity Badge */
.entity-badge.clickable {
    cursor: pointer;
    text-decoration: none;
}

.entity-badge.clickable:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

/* Entity Quick Tag with drill-through */
.entity-quick-tag .drill-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    margin-right: 4px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.entity-quick-tag .drill-link svg {
    width: 12px;
    height: 12px;
}

.entity-quick-tag .drill-link:hover {
    background: rgba(255,255,255,0.6);
    transform: scale(1.1);
}

/* Active Filters Display */
.active-filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: rgba(240, 93, 34, 0.05);
    border-radius: var(--radius-md);
    border: 1px solid rgba(240, 93, 34, 0.15);
}

.active-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-paper);
    border: 1px solid #ddd;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

.active-filter-chip .remove-filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--bg-default);
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.active-filter-chip .remove-filter:hover {
    background: var(--error);
    color: white;
}

/* ============== Responsive ============== */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    header {
        margin: -16px -16px 16px -16px;
        width: calc(100% + 32px);
    }

    header .header-content {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .file-switcher {
        flex-direction: column;
    }

    .file-switcher select {
        min-width: 100%;
    }

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

    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        min-width: 100%;
    }

    .cluster-detail-header {
        padding: 20px;
    }

    .cluster-detail-title {
        font-size: 20px;
    }

    .entities-container {
        grid-template-columns: 1fr;
    }

    .opinions-container {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
