/* Design System Variables */
:root {
    /* Colors - Monotone Base */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    /* gray-50 */
    --text-primary: #111827;
    /* gray-900 */
    --text-secondary: #4b5563;
    /* gray-600 */
    --text-tertiary: #9ca3af;
    /* gray-400 */

    /* Accent Color */
    --accent: #1e3a8a;
    /* blue-900 */
    --accent-hover: #1e40af;
    /* blue-800 */
    --accent-light: #eff6ff;
    /* blue-50 */

    /* Borders & Shadows */
    --border-color: #e5e7eb;
    /* gray-200 */
    --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 -1px rgba(0, 0, 0, 0.06);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

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

/* Global Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent);
}

/* Layout */
.container {
    max-width: 1024px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.manage-page-container {
    max-width: 1280px;
}

header {
    margin-bottom: 3rem;
}

.header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.header-nav h1 {
    flex: 0 0 auto;
    white-space: nowrap;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

/* Components - Buttons */
button,
.btn-primary,
.btn-secondary,
.btn-danger,
.upload-btn,
.new-analysis-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    font-family: var(--font-sans);
}

/* Primary Button */
.btn-primary,
.upload-btn,
.add-section-btn,
.btn-add-prompt {
    background-color: var(--text-primary);
    /* Using black/dark gray for primary */
    color: white;
}

.btn-primary:hover,
.upload-btn:hover,
.add-section-btn:hover,
.btn-add-prompt:hover {
    background-color: black;
    transform: translateY(-1px);
}

/* Secondary Button */
.btn-secondary,
.nav-link,
.modal-close {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover,
.nav-link:hover,
.modal-close:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--text-tertiary);
}

/* Danger Button */
.btn-danger {
    background-color: white;
    border: 1px solid #fee2e2;
    color: #ef4444;
}

.btn-danger:hover {
    background-color: #fee2e2;
    border-color: #ef4444;
}

/* Ghost Button / Link styled as button */
.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    background: white;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

/* Card Style */
.upload-area,
.progress-card,
.result-card,
.section-card,
.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

/* Upload Section */
.upload-area {
    text-align: center;
    border-style: dashed;
    border-width: 2px;
    cursor: pointer;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent);
    background-color: var(--accent-light);
}

.upload-icon {
    color: var(--text-tertiary);
    margin-bottom: 1.5rem;
}

.upload-area h2 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Progress Section */
.progress-card {
    max-width: 600px;
    margin: 0 auto;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

#progressCount {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    color: var(--text-primary);
}

.progress-bar {
    height: 6px;
    background-color: var(--bg-secondary);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--accent);
    width: 0%;
    transition: width 0.3s ease;
}

/* Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--bg-secondary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

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

/* Results Section */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

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

.results-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

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

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

#resultsContainer {
    display: grid;
    gap: 1.5rem;
}

.result-card {
    padding: 0;
    overflow: hidden;
}

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

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

.result-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.analysis-edit-button {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    white-space: nowrap;
}

.analysis-summary-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 12px;
}

.analysis-summary-card-header h3 {
    margin: 0;
    flex: 1;
    min-width: 0;
}

.analysis-edit-grid {
    display: grid;
    grid-template-columns: minmax(140px, 0.35fr) 1fr;
    gap: 1rem;
    align-items: end;
}

.result-content {
    padding: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
    /* Force break at any character if necessary */
    word-break: break-word;
    /* Fallback */
    word-wrap: break-word;
    /* Legacy support */
    display: block;
    min-width: 0;
    /* Allow flex item to shrink */
}

.result-content pre {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: auto;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    margin: 1rem 0;
}

.result-content code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    background-color: #f3f4f6;
    /* Equivalent to gray-100/bg-secondary ish but slightly distinct for inline */
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--accent);
}

.detail-block {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    transition: box-shadow 0.2s;
}

.detail-block:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.detail-subject {
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--border-color);
    display: flex;
    align-items: center;
}

.detail-subject::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 16px;
    background-color: var(--accent);
    margin-right: 8px;
    border-radius: 2px;
}

.detail-content {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.result-content pre code {
    background-color: transparent;
    padding: 0;
    border: none;
    font-size: inherit;
    color: inherit;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.status-badge.success {
    background-color: #ecfdf5;
    /* green-50 */
    color: #059669;
    /* green-700 */
}

.status-badge.error {
    background-color: #fef2f2;
    /* red-50 */
    color: #dc2626;
    /* red-600 */
}

.new-analysis-btn {
    margin-top: 2rem;
    width: 100%;
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.new-analysis-btn:hover {
    background-color: var(--bg-secondary);
    border-color: var(--text-tertiary);
}

/* Management Page Styles */
.management-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.section-prompts {
    width: 100%;
    /* Restore width but ensure sizing context */
    min-width: 0;
    /* Crucial for flex/grid children shrinking */
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.section-card {
    padding: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.section-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background-color: var(--bg-primary);
    width: 100%;
    box-sizing: border-box;
}

.section-header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.section-info h2 {
    font-size: 1.125rem;
    margin: 0;
}

.section-description {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    margin: 0;
    word-break: keep-all;
    overflow-wrap: break-word;
}

.prompts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
}

.prompt-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    transition: all 0.2s;
}

.prompt-card:hover {
    background-color: white;
    border-color: var(--text-tertiary);
    box-shadow: var(--shadow-sm);
}

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

.prompt-title-row h3 {
    font-size: 0.95rem;
    font-weight: 500;
}

.prompt-description-text {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
    font-style: italic;
    line-height: 1.4;
}

.prompt-content-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    line-height: 1.4;
    max-height: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prompt-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.prompt-actions .btn-secondary,
.prompt-actions .btn-danger {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-actions button {
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-actions .btn-icon {
    width: 36px;
    padding: 0;
    border: 1px solid var(--border-color);
    background-color: white;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    transition: all 0.2s;
}

.section-actions .btn-icon:hover {
    color: var(--text-primary);
    border-color: var(--text-tertiary);
    background-color: var(--bg-secondary);
}

.btn-icon {
    padding: 0.25rem;
    color: var(--text-tertiary);
    background: none;
    border: none;
    cursor: pointer;
}

/* Toggle Switch */
.toggle-switch {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background-color: #e5e7eb;
    border-radius: 9999px;
    transition: background-color 0.2s;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

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

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

/* Modals */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 50;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-primary);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-content.large {
    max-width: 800px;
}

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

.modal-header h2 {
    font-size: 1.125rem;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.global-style-content {
    max-height: 88vh;
}

.global-style-content .modal-body {
    flex: 1;
    min-height: 0;
}

.global-style-footer {
    flex-shrink: 0;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
    box-shadow: 0 -8px 18px rgba(15, 23, 42, 0.06);
}

.global-style-footer .modal-actions {
    margin-top: 1rem;
}

/* Company Info Modal Specifics */
.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex: 1 1 auto;
    justify-content: flex-end;
    min-width: 0;
    padding-bottom: 0.125rem;
}

.header-actions .nav-link,
.header-actions .btn-secondary,
.header-actions .add-section-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 0.5rem 0.75rem;
}

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

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

/* Full width for textareas and specific groups */
.form-group.full-width,
.form-grid>.form-group:nth-child(n+10) {
    grid-column: span 2;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    transition: all 0.2s;
    background-color: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.radio-group {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.radio-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 400 !important;
    margin: 0 !important;
}

.radio-label input[type="radio"] {
    width: 1.125rem !important;
    height: 1.125rem !important;
    margin: 0;
    cursor: pointer;
}

/* Company Selection Modal Specifics */
.company-select-notice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0.875rem;
    margin-bottom: 1rem;
    color: #1d4ed8;
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
}

.company-select-notice[hidden] {
    display: none;
}

.company-select-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
}

.company-select-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.company-select-item:hover {
    border-color: var(--accent);
    background-color: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.company-select-item .company-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.company-select-item .company-icon {
    width: 32px;
    height: 32px;
    background-color: #f3f4f6;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
}

.company-select-item:hover .company-icon {
    background-color: white;
    color: var(--accent);
}

.company-select-item .company-name {
    font-weight: 500;
    color: var(--text-primary);
}

.company-select-item .select-arrow {
    color: var(--text-tertiary);
    transition: transform 0.2s ease;
}

.company-select-item:hover .select-arrow {
    transform: translateX(2px);
    color: var(--accent);
}

/* Custom Scrollbar for list */
.company-select-list::-webkit-scrollbar {
    width: 6px;
}

.company-select-list::-webkit-scrollbar-track {
    background: transparent;
}

.company-select-list::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 10px;
}

.company-select-list::-webkit-scrollbar-thumb:hover {
    background: #d1d5db;
}

/* Ensure large modal has enough width and height */
.modal-content.large {
    max-width: 850px;
    width: 95%;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

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

.modal-body::-webkit-scrollbar-track {
    background-color: transparent;
}

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

.modal-body label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
    color: var(--text-primary);
}

.modal-body textarea,
.modal-body input {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.modal-body textarea:focus,
.modal-body input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

/* History Timeline Styles */
.history-timeline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.history-item {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    transition: all 0.2s;
}

.history-item:hover {
    background-color: white;
    border-color: var(--text-tertiary);
    box-shadow: var(--shadow-md);
}

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

.history-date {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.history-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.history-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

.history-badge.llm {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

.history-badge.user {
    background-color: #f0fdf4;
    color: #15803d;
    border-color: #bbf7d0;
}

.history-badge.system {
    background-color: #f8fafc;
    color: #475569;
    border-color: #cbd5e1;
}

.history-content {
    margin-top: 1rem;
}

.history-content pre {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: auto;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

.analysis-diff-content {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: auto;
    max-height: 420px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.82rem;
    line-height: 1.55;
}

.analysis-diff-block + .analysis-diff-block {
    border-top: 1px solid var(--border-color);
}

.analysis-diff-file {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.625rem 0.75rem;
    background-color: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    color: #334155;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
}

.analysis-diff-file span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.analysis-diff-file strong {
    flex: 0 0 auto;
    color: #475569;
}

.analysis-diff-hunk {
    padding: 0.25rem 0;
}

.analysis-diff-line {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr);
    padding: 0.125rem 0.75rem 0.125rem 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.analysis-diff-line.added {
    background-color: #ecfdf3;
    color: #166534;
}

.analysis-diff-line.removed {
    background-color: #fff1f2;
    color: #9f1239;
}

.analysis-diff-line.context {
    background-color: #ffffff;
    color: #475569;
}

.analysis-diff-line.omitted {
    background-color: #f8fafc;
    color: #94a3b8;
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
}

.analysis-diff-prefix {
    text-align: center;
    user-select: none;
    opacity: 0.75;
}

.analysis-diff-text {
    min-width: 0;
}

.analysis-diff-inline.added {
    background-color: #bbf7d0;
    color: #14532d;
    border-radius: 2px;
}

.analysis-diff-inline.removed {
    background-color: #fecdd3;
    color: #881337;
    border-radius: 2px;
}

.analysis-diff-empty {
    padding: 1rem;
    color: var(--text-tertiary);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    text-align: center;
}

.btn-toggle-content {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.25rem 0;
    margin-top: 0.5rem;
    text-decoration: underline;
}

.btn-toggle-content:hover {
    color: var(--accent-dark);
}

.btn-use-history {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-use-history:hover {
    background-color: var(--text-primary);
    color: white;
    border-color: var(--text-primary);
}

.btn-use-history:disabled {
    cursor: default;
    background-color: var(--bg-secondary);
    color: var(--text-tertiary);
    border-color: var(--border-color);
}

.btn-use-history:disabled:hover {
    background-color: var(--bg-secondary);
    color: var(--text-tertiary);
    border-color: var(--border-color);
}

.no-history,
.error-message {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
    padding: 2rem;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* History List Styles */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.history-list-item:hover {
    background-color: white;
    border-color: var(--text-tertiary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.history-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item-title {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 1rem;
}

.history-item-company {
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    color: var(--accent);
    background-color: var(--accent-light);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    width: fit-content;
    font-weight: 500;
}

.history-item-date {
    font-size: 0.85rem;
    color: var(--text-tertiary);
}


.history-item-arrow {
    color: var(--text-tertiary);
}

.delete-history-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-history-btn:hover {
    color: #ef4444;
    background-color: #fee2e2;
}

/* Step Switcher */
.step-switcher {
    display: inline-flex;
    background-color: var(--bg-secondary);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    gap: 0.25rem;
    margin-right: 1rem;
}

.step-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.step-btn.active {
    background-color: white;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.step-btn:hover:not(.active) {
    color: var(--text-secondary);
    background-color: rgba(0, 0, 0, 0.05);
}

.snapshot-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.snapshot-toolbar button,
.snapshot-item button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.snapshot-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 55vh;
    overflow-y: auto;
}

.snapshot-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}

.snapshot-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.snapshot-info strong {
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.snapshot-info span {
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

/* Responsive Design */
@media (max-width: 1062px) {
    .header-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .header-actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.5rem;
        width: 100%;
        justify-content: stretch;
        padding-bottom: 0;
    }

    .header-actions .nav-link,
    .header-actions .btn-secondary,
    .header-actions .add-section-btn {
        width: 100%;
        min-width: 0;
        padding: 0.5rem 0.625rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header-actions {
        grid-template-columns: 1fr 1fr;
    }

    .header-actions .nav-button,
    .header-actions .nav-link,
    .header-actions .btn-secondary,
    .header-actions .add-section-btn {
        width: 100%;
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .header-actions .step-switcher,
    .header-actions h1 {
        grid-column: span 2;
    }

    .snapshot-toolbar,
    .snapshot-item {
        flex-direction: column;
        align-items: stretch;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .form-group.full-width,
    .form-grid > .form-group:nth-child(n+1) {
        grid-column: span 1 !important;
    }

    .modal-content {
        width: 95% !important;
        max-height: 95vh !important;
    }

    .modal-content.large {
        width: 95% !important;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-actions {
        padding: 1rem;
        flex-direction: column-reverse;
    }

    .modal-actions button {
        width: 100%;
    }

    .results-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .results-actions {
        justify-content: stretch;
    }

    .download-btn {
        width: 100%;
    }

    #analysisVersionBtn {
        width: 100%;
    }

    .prompts-grid {
        grid-template-columns: 1fr !important;
        padding: 1rem;
    }

    .prompt-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .prompt-actions button {
        flex: 1 1 40%;
    }

    .step-switcher {
        width: 100%;
        margin-right: 0;
        margin-bottom: 0.5rem;
    }

    .step-btn {
        flex: 1;
        text-align: center;
    }

    .section-header-main {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .section-actions {
        justify-content: flex-end;
    }

    .upload-area {
        padding: 1.5rem;
        min-height: 250px;
    }

    .upload-area h2 {
        font-size: 1.25rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    /* JS Generated Results Responsiveness */
    .executive-summary-section {
        padding: 1rem !important;
        margin-bottom: 1.5rem !important;
    }

    .executive-summary-section h2 {
        font-size: 1.25rem !important;
        margin-bottom: 1rem !important;
    }

    #executiveSummaryContent {
        gap: 1rem !important;
    }

    .executive-summary-section div[style*="background-color: #ffffff"] {
        padding: 1rem !important;
    }

    .section-header {
        margin-top: 1.5rem !important;
        padding: 0.75rem !important;
    }

    .section-summary {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }

    .detail-block {
        padding: 1rem !important;
    }

    .detail-subject {
        font-size: 1rem !important;
    }

    .result-header {
        padding: 0.75rem 1rem !important;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .result-title {
        font-size: 0.9rem !important;
    }

    .status-badge {
        align-self: flex-end;
    }

    .result-header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .analysis-summary-card-header {
        flex-direction: column;
    }

    .analysis-edit-grid {
        grid-template-columns: 1fr;
    }
}

/* History Item Manager Badge */
.history-item-company {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.history-item-manager {
    background-color: #ef4444; /* Red color */
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    min-width: 18px;
    height: 18px;
}
