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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 0;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-light);
    font-size: 1.1rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    margin-bottom: -2px;
}

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

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text);
}

.card h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--text);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text);
}

textarea, input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

textarea:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

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

.btn-loader {
    display: inline-block;
}

/* File Upload */
.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 20px;
}

.file-upload-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.file-upload-area.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.upload-content svg {
    color: var(--text-light);
    margin-bottom: 10px;
}

.upload-content p {
    color: var(--text-light);
    margin: 5px 0;
}

.link-text {
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}

.file-name {
    color: var(--text);
    font-weight: 500;
    margin-top: 10px;
}

/* Progress Bar */
.progress-container {
    margin: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s;
    border-radius: 4px;
}

.progress-text {
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Results */
.results-container {
    margin-top: 30px;
}

.aspect-result {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.aspect-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.aspect-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
}

.consensus-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.avg-score {
    padding: 8px 16px;
    background: var(--bg);
    border-radius: 8px;
    font-weight: 500;
}

.consensus-badge {
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
}

.consensus-badge.tight {
    background: #fee2e2;
    color: #991b1b;
}

.consensus-badge.perfect {
    background: #d1fae5;
    color: #065f46;
}

.consensus-badge.loose {
    background: #dbeafe;
    color: #1e40af;
}

.single-aspect-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 10px;
}

.sentiment-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 120px;
    text-align: center;
}

.sentiment-badge.tight {
    background: #fee2e2;
    color: #991b1b;
}

.sentiment-badge.perfect {
    background: #d1fae5;
    color: #065f46;
}

.sentiment-badge.loose {
    background: #dbeafe;
    color: #1e40af;
}

.sentiment-badge.irrelevant {
    background: #f3f4f6;
    color: #4b5563;
}

.confidence {
    color: var(--text-light);
    font-size: 0.9rem;
}

.chart-container {
    margin-top: 20px;
    height: 300px;
    position: relative;
}

/* Overall fit widget (batch analysis) */
.overall-fit-widget {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 28px;
}

.overall-fit-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
    line-height: 1.2;
}

.overall-fit-statement {
    font-size: 1.05rem;
    color: var(--text);
    margin-bottom: 10px;
}

.overall-fit-category {
    color: var(--primary);
    font-weight: 700;
}

.overall-fit-explanation {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.5;
}

/* Info Text */
.info-text {
    color: var(--text-light);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.info-text a {
    color: var(--primary);
    text-decoration: none;
}

.info-text a:hover {
    text-decoration: underline;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--card-bg);
    margin: 10% auto;
    padding: 30px;
    border-radius: 12px;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: var(--text);
}

.modal-content h2 {
    margin-bottom: 15px;
}

.modal-content pre {
    background: var(--bg);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 15px 0;
    border: 1px solid var(--border);
}

.modal-content code {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.modal-large {
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.reviews-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.review-item {
    display: flex;
    gap: 15px;
    padding: 15px;
    background: var(--bg);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
    transition: transform 0.2s, box-shadow 0.2s;
}

.review-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow);
}

.review-number {
    min-width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.review-text {
    flex: 1;
    color: var(--text);
    line-height: 1.6;
    padding-top: 4px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* Confusion Matrix & Metrics Styles */
.metrics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: var(--bg);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 2px solid var(--border);
}

.metric-label {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 10px;
    font-weight: 500;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.metric-formula {
    font-size: 0.75rem;
    color: var(--text-light);
    font-style: italic;
}

.confusion-matrix-container {
    margin: 30px 0;
    text-align: center;
}

.confusion-matrix-container h4 {
    margin-bottom: 20px;
    color: var(--text);
}

.confusion-matrix-img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.metrics-detail {
    margin: 30px 0;
}

.metrics-detail h4 {
    margin-bottom: 15px;
    color: var(--text);
}

.metrics-table {
    overflow-x: auto;
}

.metrics-table table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.metrics-table thead {
    background: var(--primary);
    color: white;
}

.metrics-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

.metrics-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

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

.metrics-table tbody tr:last-child td {
    border-bottom: none;
}

.formulas-section {
    margin: 30px 0;
    padding: 20px;
    background: var(--bg);
    border-radius: 8px;
}

.formulas-section h4 {
    margin-bottom: 20px;
    color: var(--text);
}

.formula-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.formula-item {
    padding: 15px;
    background: var(--card-bg);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.formula-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.formula-equation {
    color: var(--text-light);
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    background: var(--bg);
    padding: 8px;
    border-radius: 4px;
}

/* Extractor model selector */
.extractor-model-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.extractor-model-group label {
    margin-bottom: 0;
}

.extractor-model-group select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid var(--border);
    font-size: 0.95rem;
    font-family: inherit;
}

.rule-legend-card {
    margin-top: 20px;
}

.rule-legend-list {
    margin-left: 18px;
    margin-top: 10px;
    color: var(--text-light);
    font-size: 0.9rem;
}

.rule-legend-list li + li {
    margin-top: 6px;
}

/* Extractor Performance: review list */
.extractor-reviews-list {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 8px;
}

.extractor-review-card {
    display: flex;
    gap: 16px;
    padding: 20px;
    margin-bottom: 16px;
    background: var(--bg);
    border-radius: 10px;
    border-left: 4px solid var(--primary);
    transition: box-shadow 0.2s;
}

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

.extractor-review-index {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
}

.extractor-review-body {
    flex: 1;
    min-width: 0;
}

.extractor-review-text {
    color: var(--text);
    margin-bottom: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
}

.extractor-review-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.extractor-review-row:last-child {
    margin-bottom: 0;
}

.extractor-label-tag {
    flex-shrink: 0;
    min-width: 72px;
    padding: 4px 8px;
    background: var(--border);
    color: var(--text-light);
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.8rem;
}

.extractor-label-tag.predicted {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
}

.extractor-aspects {
    color: var(--text);
    word-break: break-word;
}

.extractor-review-metrics {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 500;
}

.extractor-metric {
    padding: 4px 8px;
    border-radius: 4px;
}

.extractor-metric.tp {
    background: rgba(16, 185, 129, 0.15);
    color: #065f46;
}

.extractor-metric.fp {
    background: rgba(245, 158, 11, 0.2);
    color: #92400e;
}

.extractor-metric.fn {
    background: rgba(239, 68, 68, 0.15);
    color: #991b1b;
}

/* Attribution */
.attribution {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 400;
    letter-spacing: 0.5px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
    transition: opacity 0.2s;
}

.attribution:hover {
    opacity: 0.8;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .card {
        padding: 20px;
    }
    
    .aspect-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .metrics-summary {
        grid-template-columns: 1fr;
    }
    
    .formula-grid {
        grid-template-columns: 1fr;
    }
}
