:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --eligible: #10b981;
    --eligible-bg: rgba(16, 185, 129, 0.1);
    --ineligible: #ef4444;
    --ineligible-bg: rgba(239, 68, 68, 0.1);
    --review: #f59e0b;
    --review-bg: rgba(245, 158, 11, 0.1);
    --critical: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Header */
.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.app-title span { color: var(--accent); }

.app-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.header-badge {
    background: var(--accent);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    gap: 0;
}

.nav-tab {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.nav-tab:hover { color: var(--text-primary); }
.nav-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Main Content */
.main-content { padding: 1.5rem 2rem; max-width: 1400px; margin: 0 auto; }

.tab-section { display: none; }
.tab-section.active { display: block; }

/* Section Headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

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

/* Stat Cards */
#stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    text-align: center;
}

.stat-card.eligible { border-color: var(--eligible); background: var(--eligible-bg); }
.stat-card.ineligible { border-color: var(--ineligible); background: var(--ineligible-bg); }
.stat-card.review { border-color: var(--review); background: var(--review-bg); }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card.eligible .stat-value { color: var(--eligible); }
.stat-card.ineligible .stat-value { color: var(--ineligible); }
.stat-card.review .stat-value { color: var(--review); }

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
}

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

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

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

.data-table tr:hover td { background: var(--bg-card-hover); }

.text-center { text-align: center; }

/* Bar Chart */
.bar-cell { background: var(--bg-primary); border-radius: 4px; height: 20px; overflow: hidden; }
.bar-fill { background: var(--ineligible); height: 100%; border-radius: 4px; transition: width 0.3s; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-eligible { background: var(--eligible-bg); color: var(--eligible); border: 1px solid var(--eligible); }
.badge-ineligible { background: var(--ineligible-bg); color: var(--ineligible); border: 1px solid var(--ineligible); }
.badge-review_required { background: var(--review-bg); color: var(--review); border: 1px solid var(--review); }
.badge-critical { background: var(--ineligible-bg); color: var(--ineligible); }
.badge-warning { background: var(--review-bg); color: var(--review); }
.badge-info { background: rgba(59, 130, 246, 0.1); color: var(--info); }

/* Validator Form */
.validator-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.full-width { grid-column: 1 / -1; }

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-select {
    padding: 0.6rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 100%;
}

.form-select:disabled { opacity: 0.5; }

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover { background: var(--bg-card-hover); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Validation Results */
.validation-result {
    border-radius: 0.75rem;
    overflow: hidden;
    margin-top: 1rem;
}

.result-eligible { border: 1px solid var(--eligible); }
.result-ineligible { border: 1px solid var(--ineligible); }
.result-review { border: 1px solid var(--review); }

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
}

.result-eligible .result-header { background: var(--eligible-bg); }
.result-ineligible .result-header { background: var(--ineligible-bg); }
.result-review .result-header { background: var(--review-bg); }

.result-badge {
    font-size: 1.1rem;
    font-weight: 700;
}

.result-eligible .result-badge { color: var(--eligible); }
.result-ineligible .result-badge { color: var(--ineligible); }
.result-review .result-badge { color: var(--review); }

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

.rules-breakdown { padding: 0.5rem; }

.rule-item {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    background: var(--bg-primary);
}

.rule-pass { border-left: 3px solid var(--eligible); }
.rule-fail { border-left: 3px solid var(--ineligible); }
.rule-warn { border-left: 3px solid var(--review); }

.rule-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.rule-icon { font-size: 1rem; }
.rule-name { font-weight: 600; font-size: 0.85rem; flex: 1; }

.rule-message {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.rule-details {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Audit Filters */
.audit-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

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

.filter-btn:hover { background: var(--bg-card-hover); }
.filter-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.detail-btn {
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--accent);
    font-size: 0.75rem;
    cursor: pointer;
}

.detail-btn:hover { background: var(--bg-card-hover); }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 1.5rem;
}

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Loading / Error */
.loading { color: var(--text-secondary); padding: 1rem; text-align: center; }
.error-msg { color: var(--ineligible); padding: 1rem; }

/* Batch Status */
#batch-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .validator-form { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    #stats-cards { grid-template-columns: repeat(2, 1fr); }
    .main-content { padding: 1rem; }
    .app-header { padding: 0.75rem 1rem; }
    .nav-tabs { padding: 0 1rem; overflow-x: auto; }
}

/* Architecture Page */
.arch-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.arch-section h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

.arch-diagram {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    background: var(--bg-primary);
    padding: 1.5rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    white-space: pre;
    color: var(--text-primary);
}

.arch-list { list-style: none; padding: 0; }
.arch-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.arch-list li:last-child { border-bottom: none; }

.tech-tag {
    display: inline-block;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    margin: 0.1rem;
}
