/* ====================================
   AI 合同审查助手 - 全局样式 (Modern SaaS Light Theme)
   ==================================== */

:root {
    /* Colors - Brand (Bright Blue) */
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --primary-bg: #eff6ff;
    --accent: #0ea5e9;

    /* Semantic Colors */
    --risk-high: #ef4444;
    --risk-high-bg: #fef2f2;
    --risk-medium: #f59e0b;
    --risk-medium-bg: #fffbeb;
    --risk-low: #3b82f6;
    --risk-low-bg: #eff6ff;
    --risk-none: #10b981;
    --risk-none-bg: #ecfdf5;

    /* Backgrounds */
    --bg: #f8fafc;
    /* App background, very light cool gray */
    --bg-card: #ffffff;
    /* Pure white cards */
    --bg-elevated: #f1f5f9;
    /* Elevated background */
    --bg-hover: #f1f5f9;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;

    /* Typography */
    --text: #0f172a;
    /* Slate 900 - Primary text */
    --text-secondary: #475569;
    /* Slate 600 - Secondary text */
    --text-muted: #94a3b8;
    /* Slate 400 - Muted text */

    /* Font */
    --font: 'Noto Sans SC', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing & Borders */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

    /* Transitions */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

#app {
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* ====================================
   Page transitions
   ==================================== */
.page {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    overflow-y: auto;
    padding: 40px 24px;
    opacity: 0;
    transform: translateX(40px);
    pointer-events: none;
    transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}

.page.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: all;
}

.page.exit-left {
    opacity: 0;
    transform: translateX(-40px);
}

/* ====================================
   Glass card (Adjusted for Light Theme)
   ==================================== */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    /* Removed heavy backdrop-filter for clean SaaS look */
}

/* ====================================
   Page 1: Upload
   ==================================== */
.upload-container {
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    min-height: 100%;
}

.brand {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 64px;
    height: 64px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.brand h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    /* Removed gradient text for cleaner SaaS feel */
}

.brand-subtitle {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 400;
}

.upload-zone {
    width: 100%;
    border: 2px dashed var(--border-hover);
    border-radius: var(--radius-lg);
    padding: 64px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s var(--ease);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.upload-zone .upload-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    color: var(--text-muted);
    transition: color 0.3s var(--ease);
}

.upload-zone:hover .upload-icon {
    color: var(--primary-light);
}

.upload-text {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 6px;
}

.upload-hint {
    font-size: 14px;
    color: var(--text-secondary);
}

.upload-link {
    color: var(--primary-light);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.upload-format {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 12px;
}

/* File info */
.file-info {
    width: 100%;
}

.file-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    animation: slideUp 0.3s var(--ease);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-icon {
    font-size: 28px;
}

.file-details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
}

.file-size {
    font-size: 12px;
    color: var(--text-muted);
}

.file-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.file-remove:hover {
    color: var(--risk-high);
    background: var(--risk-high-bg);
}

/* Upload config area */
.upload-config-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: slideUp 0.4s var(--ease);
}

.config-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.config-section-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* Scale group (促成交易 / 平衡审查 / 严格把关) */
.scale-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.scale-option {
    cursor: pointer;
}

.scale-card {
    padding: 16px 12px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    transition: all 0.25s var(--ease);
    box-shadow: var(--shadow-sm);
}

.scale-card:hover {
    border-color: var(--primary-light);
    background: var(--primary-bg);
}

.scale-option.selected .scale-card,
.scale-option input:checked ~ .scale-card {
    border-color: var(--primary);
    background: var(--primary-bg);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.scale-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.scale-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Focus tags area */
.focus-tags-area {
    min-height: 44px;
}

.focus-tags-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
}

.tags-shimmer {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: tagspin 0.8s linear infinite;
}

@keyframes tagspin {
    to { transform: rotate(360deg); }
}

.focus-tags-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.focus-chip {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s var(--ease);
    box-shadow: var(--shadow-sm);
}

.focus-chip:hover {
    border-color: var(--primary-light);
    color: var(--primary);
    background: var(--primary-bg);
}

.focus-chip.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.focus-custom-input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-card);
    transition: border-color 0.2s;
    margin-top: 4px;
}

.focus-custom-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.focus-custom-input::placeholder {
    color: var(--text-muted);
}

/* Advanced collapsible section */
.advanced-section {
    width: 100%;
}

.advanced-toggle {
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px 0;
    list-style: none;
    transition: color 0.2s;
    user-select: none;
}

.advanced-toggle::-webkit-details-marker {
    display: none;
}

.advanced-toggle::before {
    content: '▸ ';
}

details[open] .advanced-toggle::before {
    content: '▾ ';
}

.advanced-toggle:hover {
    color: var(--primary);
}

.advanced-content {
    padding-top: 10px;
    animation: slideUp 0.3s var(--ease);
}

/* Optional tag badge */
.optional-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    vertical-align: middle;
}

/* ====================================
   Buttons
   ==================================== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.3s var(--ease);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
    /* Adapted for blue */
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

.btn-primary:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn-back:hover {
    color: var(--text);
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.3s var(--ease);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.btn-download:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* ====================================
   Page 2: Analysis Report (Rich)
   ==================================== */
.analysis-container {
    width: 100%;
    max-width: 800px;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 600;
}

/* Loading — staged messages + skeleton */
.analysis-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 0 20px;
}

.loading-stage-icon {
    font-size: 40px;
    animation: loadingBounce 1.5s ease-in-out infinite;
}

@keyframes loadingBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.loading-stage-text {
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    min-height: 22px;
    transition: opacity 0.3s;
}

.loading-progress-bar {
    width: 280px;
    height: 4px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}

.loading-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), #818cf8);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Skeleton preview */
.skeleton-preview {
    width: 100%;
    max-width: 600px;
    margin-top: 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.skeleton-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.skeleton-title {
    width: 120px;
    height: 16px;
    border-radius: 4px;
    background: var(--border);
    animation: shimmer 1.5s ease-in-out infinite alternate;
}

.skeleton-row-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-row {
    height: 12px;
    border-radius: 3px;
    background: var(--border);
    animation: shimmer 1.5s ease-in-out infinite alternate;
}

.skeleton-row.short {
    width: 40%;
}

.skeleton-row.medium {
    width: 65%;
}

.skeleton-row.long {
    width: 90%;
}

.skeleton-badges {
    display: flex;
    gap: 12px;
}

.skeleton-badge {
    width: 60px;
    height: 36px;
    border-radius: 8px;
    background: var(--border);
    animation: shimmer 1.5s ease-in-out infinite alternate;
}

@keyframes shimmer {
    0% {
        opacity: 0.4;
    }

    100% {
        opacity: 0.8;
    }
}

/* Section blocks */
.section-block {
    margin-bottom: 28px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.section-title svg {
    color: var(--primary);
    flex-shrink: 0;
}

/* Contract Metadata Grid */
.contract-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.meta-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
}

.meta-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    word-break: break-all;
}

.meta-highlight {
    color: var(--primary);
    font-size: 18px;
}

/* Donut Chart */
.risk-distribution {
    display: flex;
    align-items: center;
    gap: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    box-shadow: var(--shadow-sm);
}

.donut-chart-wrapper {
    position: relative;
    width: 160px;
    height: 160px;
    flex-shrink: 0;
}

.donut-chart {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.donut-total {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    font-family: 'Inter', sans-serif;
}

.donut-label {
    font-size: 12px;
    color: var(--text-muted);
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-text {
    font-size: 14px;
    color: var(--text-secondary);
    flex: 1;
}

.legend-count {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    min-width: 24px;
    text-align: right;
}

/* Key Findings */
.key-findings {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.finding-card {
    display: flex;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    border-left: 3px solid var(--risk-high);
    transition: transform 0.2s, box-shadow 0.2s;
}

.finding-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.finding-card.medium {
    border-left-color: var(--risk-medium);
}

.finding-card.low {
    border-left-color: var(--risk-low);
}

.finding-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: var(--risk-high);
    flex-shrink: 0;
}

.finding-card.medium .finding-number {
    background: var(--risk-medium);
}

.finding-card.low .finding-number {
    background: var(--risk-low);
}

.finding-content {
    flex: 1;
}

.finding-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.finding-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Structure Overview */
.structure-overview {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.structure-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    transition: background 0.2s;
}

.structure-item:hover {
    background: var(--bg-hover);
}

.structure-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.structure-count {
    font-size: 13px;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 2px 10px;
    border-radius: 20px;
}

.structure-risks {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.risk-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.risk-dot.high {
    background: var(--risk-high);
}

.risk-dot.medium {
    background: var(--risk-medium);
}

.risk-dot.low {
    background: var(--risk-low);
}

/* Report */
.analysis-report {
    padding: 24px 28px;
    line-height: 1.8;
    font-size: 15px;
    color: var(--text);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

/* ====================================
   Page 3: Config
   ==================================== */
.config-container {
    width: 100%;
    max-width: 720px;
}

/* Stats (removed from analysis, kept for reference) */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-card-risk {
    border-color: var(--risk-high);
    background: var(--risk-high-bg);
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    font-family: 'Inter', sans-serif;
}

.stat-card-risk .stat-value {
    color: var(--risk-high);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Divider */
.divider {
    height: 1px;
    background: var(--border);
    margin: 24px 0;
}

/* Form */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 32px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.optional-tag {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    padding: 2px 8px;
    background: var(--bg-elevated);
    border-radius: 20px;
}

.form-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* Radio */
.radio-group {
    display: flex;
    gap: 8px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.radio-option:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.radio-option input[type="radio"] {
    accent-color: var(--primary);
}

.radio-option input[type="radio"]:checked+span {
    color: var(--primary-light);
    font-weight: 500;
}

/* Checkbox */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    line-height: 1.5;
    background: var(--bg-card);
}

.checkbox-option:hover {
    border-color: var(--primary-light);
    background: var(--bg-hover);
}

.checkbox-option input[type="checkbox"] {
    accent-color: var(--primary);
    margin-top: 2px;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

/* Textarea */
.form-textarea {
    width: 100%;
    min-height: 100px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-textarea::placeholder {
    color: var(--text-muted);
}

/* ====================================
   Page 3: Progress
   ==================================== */
.progress-container {
    width: 100%;
    max-width: 720px;
}

.progress-bar-wrapper {
    margin-bottom: 32px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-elevated);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 20px;
    transition: width 0.6s var(--ease);
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 30px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3));
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {

    0%,
    100% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Blocks */
.blocks-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.block-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    animation: slideUp 0.4s var(--ease);
}

.block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.block-header .status-icon {
    font-size: 16px;
}

.block-clauses {
    padding: 8px 0;
}

.clause-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    font-size: 13px;
    color: var(--text-secondary);
    transition: background 0.2s;
}

.clause-item:hover {
    background: var(--bg-hover);
}

.clause-name {
    flex: 1;
}

.clause-status {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.clause-status.none {
    background: var(--risk-none-bg);
    color: var(--risk-none);
}

.clause-status.low {
    background: var(--risk-low-bg);
    color: var(--risk-low);
}

.clause-status.medium {
    background: var(--risk-medium-bg);
    color: var(--risk-medium);
}

.clause-status.high {
    background: var(--risk-high-bg);
    color: var(--risk-high);
}

.clause-status.pending {
    background: var(--bg-elevated);
    color: var(--text-muted);
}

.clause-status.reviewing {
    background: var(--primary-bg);
    color: var(--primary-light);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ====================================
   Page 4: Result
   ==================================== */
.result-container {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.result-header h2 {
    font-size: 22px;
    font-weight: 600;
}

.result-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Filter */
.filter-group {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.filter-btn {
    padding: 6px 14px;
    background: none;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-family: var(--font);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-btn:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.filter-btn.active {
    color: #fff;
    background: var(--text);
    box-shadow: var(--shadow-sm);
}

/* Summary */
.result-summary {
    padding: 20px 24px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.8;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.summary-text {
    flex: 1;
}

.summary-badges {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.summary-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    min-width: 60px;
}

.summary-badge .badge-count {
    font-size: 20px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
}

.summary-badge.high {
    background: var(--risk-high-bg);
    color: var(--risk-high);
}

.summary-badge.medium {
    background: var(--risk-medium-bg);
    color: var(--risk-medium);
}

.summary-badge.low {
    background: var(--risk-low-bg);
    color: var(--risk-low);
}

.summary-badge.none {
    background: var(--risk-none-bg);
    color: var(--risk-none);
}

/* Result body */
.result-body {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

/* Contract panel */
.contract-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 40px;
    overflow-y: auto;
    line-height: 2;
    font-size: 15px;
    /* Slightly larger text for readability */
    box-shadow: var(--shadow-sm);
}

.contract-clause {
    margin-bottom: 32px;
    padding: 20px 24px;
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
    transition: all 0.3s;
    background: #fff;
    /* Keep clauses white */
}

.contract-clause:hover {
    background: var(--bg-hover);
}

.contract-clause.highlight {
    background: var(--primary-bg);
    border-left-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary-light);
}

.contract-clause.risk-high {
    border-left-color: var(--risk-high);
}

.contract-clause.risk-medium {
    border-left-color: var(--risk-medium);
}

.contract-clause.risk-low {
    border-left-color: var(--risk-low);
}

.clause-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.clause-risk-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

.clause-risk-tag.high {
    background: var(--risk-high-bg);
    color: var(--risk-high);
}

.clause-risk-tag.medium {
    background: var(--risk-medium-bg);
    color: var(--risk-medium);
}

.clause-risk-tag.low {
    background: var(--risk-low-bg);
    color: var(--risk-low);
}

.clause-body {
    color: var(--text-secondary);
}

/* Markup styles */
.text-added {
    color: var(--risk-high);
    font-weight: 500;
    background: var(--risk-high-bg);
    padding: 1px 4px;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.2s;
}

.text-added:hover {
    background: rgba(239, 68, 68, 0.16);
}

.text-deleted {
    color: var(--text-muted);
    text-decoration: line-through;
    opacity: 0.6;
    cursor: pointer;
    transition: opacity 0.2s;
}

.text-deleted:hover {
    opacity: 1;
}

.text-commented {
    border-bottom: 2px dashed var(--risk-low);
    cursor: pointer;
    transition: background 0.2s;
    padding-bottom: 1px;
}

.text-commented:hover {
    background: var(--risk-low-bg);
}

.comment-anchor {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    vertical-align: super;
    margin-left: 2px;
    transition: transform 0.2s;
    font-family: 'Inter', sans-serif;
}

.comment-anchor:hover {
    transform: scale(1.2);
}

/* Comment panel */
.comment-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    min-height: 0;
    box-shadow: var(--shadow-sm);
}

.comment-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.comment-panel-header h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.comment-stats {
    font-size: 13px;
    /* Slightly larger */
    color: var(--text-secondary);
}

.comment-list {
    overflow-y: auto;
    flex: 1;
    padding: 16px;
    background: var(--bg);
    /* Light grey inside the scroll area */
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.comment-card {
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    line-height: 1.7;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.comment-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.comment-card.active {
    border-color: var(--primary);
    background: var(--primary-bg);
    box-shadow: 0 0 0 1px var(--primary);
}

.comment-card.high {
    border-left: 3px solid var(--risk-high);
}

.comment-card.medium {
    border-left: 3px solid var(--risk-medium);
}

.comment-card.low {
    border-left: 3px solid var(--risk-low);
}

.comment-card.missing {
    border-left: 3px solid var(--accent);
}

.comment-label {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.comment-label.high {
    color: var(--risk-high);
}

.comment-label.medium {
    color: var(--risk-medium);
}

.comment-label.low {
    color: var(--risk-low);
}

.comment-label.missing {
    color: var(--accent);
}

.comment-ref {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ====================================
   Scrollbar
   ==================================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ====================================
   Responsive
   ==================================== */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .result-body {
        grid-template-columns: 1fr;
    }

    .comment-panel {
        max-height: 300px;
    }

    .stat-cards {
        grid-template-columns: 1fr;
    }

    .result-actions {
        flex-wrap: wrap;
    }

    .result-summary {
        flex-direction: column;
    }
}

/* ====================================
   Settings FAB + Modal
   ==================================== */
.settings-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    z-index: 1000;
}

.settings-fab:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: rotate(30deg);
}

.settings-fab.configured {
    border-color: var(--risk-low);
    color: var(--risk-low);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 520px;
    margin: 0 20px;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Provider tabs */
.provider-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.provider-tab {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.provider-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.provider-tab.active {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

/* Form */
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    margin-top: 14px;
}

.form-label:first-child {
    margin-top: 0;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.modal-status {
    margin-top: 14px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: none;
}

.modal-status.success {
    display: block;
    background: var(--risk-low-bg, #ecfdf5);
    color: var(--risk-low, #10b981);
    border: 1px solid var(--risk-low, #10b981);
}

.modal-status.error {
    display: block;
    background: var(--risk-high-bg);
    color: var(--risk-high);
    border: 1px solid var(--risk-high);
}

.modal-status.info {
    display: block;
    background: var(--primary-bg);
    color: var(--primary);
    border: 1px solid var(--primary);
}

/* Small button variant */
.btn-sm {
    padding: 8px 20px;
    font-size: 14px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

/* ====================================
   Progress Page - Stats & Three-State
   ==================================== */
.review-stats-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 24px;
    margin-bottom: 20px;
}

.review-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.review-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    font-feature-settings: 'tnum';
}

.review-stat-value.stat-modify {
    color: var(--risk-high);
}

.review-stat-value.stat-comment {
    color: var(--primary);
}

.review-stat-value.stat-time {
    font-size: 16px;
    color: var(--text-secondary);
}

.review-stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

.review-stat-divider {
    width: 1px;
    height: 36px;
    background: var(--border);
    margin: 0 8px;
}

/* Block cards: three states */
.block-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.block-card.waiting {
    opacity: 0.5;
}

.block-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.15);
    }
}

.block-card.completed {
    opacity: 1;
    border-color: var(--border);
}

.block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.block-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.block-card.waiting .block-title {
    color: var(--text-muted);
}

.block-status-icon {
    display: flex;
    align-items: center;
    color: var(--text-muted);
}

.block-card.active .block-status-icon {
    color: var(--primary);
}

.block-card.completed .block-status-icon {
    color: var(--risk-low);
}

.block-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.block-risk-badges {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.risk-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.risk-badge.high {
    background: var(--risk-high-bg);
    color: var(--risk-high);
}

.risk-badge.medium {
    background: var(--risk-medium-bg);
    color: var(--risk-medium);
}

.risk-badge.low {
    background: rgba(59, 130, 246, 0.08);
    color: var(--primary);
}

/* Spin icon animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spin-icon {
    animation: spin 1.2s linear infinite;
}

/* ====================================
   Result Page - Inline Diff & Enhancements
   ==================================== */
.clause-diff {
    margin-top: 8px;
    padding: 12px 16px;
    font-size: 13px;
    line-height: 2;
    background: var(--bg);
    border-radius: 6px;
}

.clause-diff del {
    text-decoration: line-through;
    color: var(--risk-high);
    background: rgba(239, 68, 68, 0.08);
    padding: 1px 2px;
    border-radius: 2px;
}

.clause-diff ins {
    text-decoration: underline;
    color: var(--risk-high);
    background: rgba(239, 68, 68, 0.06);
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 500;
}

/* Annotation anchors — ❶❷❸ superscript */
.annotation-anchor {
    display: inline-block;
    font-size: 14px;
    color: var(--primary);
    cursor: pointer;
    vertical-align: super;
    margin-left: 4px;
    transition: transform 0.2s;
    text-decoration: none;
}

.annotation-anchor:hover {
    transform: scale(1.3);
    color: var(--risk-high);
}

/* Clickable comment ref */
.comment-ref {
    cursor: pointer;
    transition: color 0.2s;
}

.comment-ref:hover {
    color: var(--primary);
}

/* Highlight flash when scrolled to */
@keyframes annotationFlash {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.15);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

.annotation-highlight {
    animation: annotationFlash 0.8s ease-out 2;
}

.clause-original {
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.8;
    color: var(--text-secondary);
    background: var(--bg);
    border-radius: 4px;
}

.clause-comment {
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    background: rgba(59, 130, 246, 0.04);
    border-radius: 4px;
    border-left: 3px solid var(--primary);
}

.clause-risk-tag.missing {
    background: rgba(168, 85, 247, 0.1);
    color: #7c3aed;
}

.contract-clause.risk-missing {
    border-left-color: #7c3aed;
}

.summary-badge.missing {
    background: rgba(168, 85, 247, 0.1);
    color: #7c3aed;
}