/* ============================================
   AeroForge Design Intelligence — Design System
   ============================================ */


@import url("./core/tokens.css");

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(124, 58, 237, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(6, 182, 212, 0.06) 0%, transparent 60%);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* --- Header --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--cyan));
    border-radius: var(--radius-sm);
    box-shadow: 0 0 20px var(--accent-glow);
}

.header-brand h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.header-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.header-actions { display: flex; gap: 0.5rem; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}
.btn-ghost:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-input);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #6d28d9);
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-small {
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1px dashed var(--border-input);
}
.btn-outline:hover {
    background: var(--accent-glow);
    border-style: solid;
}

.btn-analyze {
    width: 100%;
    padding: 0.85rem;
    font-size: 1rem;
    margin-top: 1rem;
    border-radius: var(--radius-md);
    justify-content: center;
}

.btn-icon { font-size: 1.1em; }

.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-family: var(--font);
    font-size: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.link-btn:hover { color: var(--cyan); }

/* --- Layout --- */
.app-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.panel-input {
    overflow-y: auto;
    padding: 1rem;
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    scrollbar-width: thin;
    scrollbar-color: var(--accent-glow) transparent;
}

.panel-results {
    overflow-y: auto;
    padding: 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-glow) transparent;
}

/* --- Form Sections --- */
.form-section {
    margin-bottom: 0.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    transition: border-color var(--transition);
}
.form-section:hover { border-color: var(--border-input); }

.section-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 0.9rem;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}
.section-toggle:hover { background: var(--bg-card-hover); }

.section-icon { font-size: 1.05rem; }

.chevron {
    margin-left: auto;
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: transform var(--transition);
}

.form-section.open .chevron { transform: rotate(90deg); }

.section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 0.9rem;
}

.form-section.open .section-body {
    max-height: 600px;
    padding: 0 0.9rem 0.9rem;
}

/* --- Form Fields --- */
.field { margin-bottom: 0.6rem; }

.field label {
    display: block;
    margin-bottom: 0.2rem;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.field input,
.field select {
    width: 100%;
    padding: 0.5rem 0.65rem;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.field input:focus,
.field select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.field input::placeholder { color: var(--text-muted); }

.field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239ba3b5'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 2rem;
}

.field select option { background: var(--bg-secondary); color: var(--text-primary); }

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

/* --- Mass Row --- */
.mass-row {
    display: grid;
    grid-template-columns: 1fr 0.6fr 0.5fr auto;
    gap: 0.4rem;
    align-items: end;
    margin-bottom: 0.4rem;
}

.mass-row input { font-size: 0.8rem; padding: 0.4rem 0.5rem; }

.btn-remove-mass {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--severity-critical-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--severity-critical);
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--transition);
    margin-bottom: 0.6rem;
}
.btn-remove-mass:hover { background: var(--bg-card); }

/* --- Empty / Loading States --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    gap: 0.8rem;
}

.empty-icon {
    font-size: 4rem;
    opacity: 0.6;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.empty-state h2 {
    font-size: 1.4rem;
    color: var(--text-heading);
    font-weight: 600;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    max-width: 340px;
}

.empty-hint { font-size: 0.82rem !important; color: var(--text-muted) !important; }

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 1.2rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state p { color: var(--text-secondary); font-size: 0.95rem; }

.hidden { display: none !important; }

/* --- Results Content --- */
.result-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.8rem 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.summary-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-heading);
}

.summary-meta { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.badge {
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid var(--border-input);
}

/* --- Confidence Banner --- */
.confidence-banner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.2rem;
    margin-bottom: 1.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
}

.conf-score {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    transition: color 0.5s ease;
}

.conf-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.7;
}

.conf-bar-wrap {
    height: 8px;
    border-radius: 4px;
    background: var(--bg-card);
    overflow: hidden;
}

.conf-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease, background 0.5s ease;
    background: var(--conf-medium);
}

.conf-title {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Confidence color states */
.confidence-banner.high .conf-score,
.confidence-banner.high .conf-bar { color: var(--conf-high); background: var(--conf-high); }
.confidence-banner.medium .conf-score,
.confidence-banner.medium .conf-bar { color: var(--conf-medium); background: var(--conf-medium); }
.confidence-banner.low .conf-score,
.confidence-banner.low .conf-bar { color: var(--conf-low); background: var(--conf-low); }
.confidence-banner.very_low .conf-score,
.confidence-banner.very_low .conf-bar { color: var(--conf-very-low); background: var(--conf-very-low); }

.confidence-banner.high .conf-score { color: var(--conf-high); }
.confidence-banner.medium .conf-score { color: var(--conf-medium); }
.confidence-banner.low .conf-score { color: var(--conf-low); }
.confidence-banner.very_low .conf-score { color: var(--conf-very-low); }

/* --- Section Titles --- */
.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-heading);
    margin: 1.4rem 0 0.7rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    background: var(--accent-glow);
    color: var(--accent);
}

/* --- Metric Cards --- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.6rem;
    max-width: 900px;
}

.metric-card {
    padding: 0.8rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--cyan));
    opacity: 0;
    transition: opacity var(--transition);
}

.metric-card:hover {
    border-color: var(--border-input);
    transform: translateY(-2px);
}
.metric-card:hover::before { opacity: 1; }

.metric-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-heading);
    line-height: 1.1;
    margin-bottom: 0.15rem;
}

.metric-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.metric-unit {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Metric card status colors */
.metric-card.good .metric-value { color: var(--conf-high); }
.metric-card.warn .metric-value { color: var(--severity-warning); }
.metric-card.bad .metric-value { color: var(--severity-critical); }

.metric-card.danger {
    background: var(--severity-critical-bg);
    border-color: var(--severity-critical);
}
.metric-card.danger .metric-value { color: var(--severity-critical); }

/* --- Findings --- */
.findings-list, .recommendations-list, .assumptions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.finding-card {
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
    border-left: 3px solid;
    transition: all var(--transition);
}

.finding-card:hover { transform: translateX(3px); }

.finding-card.critical {
    background: var(--severity-critical-bg);
    border-color: var(--severity-critical);
}
.finding-card.warning {
    background: var(--severity-warning-bg);
    border-color: var(--severity-warning);
}
.finding-card.info {
    background: var(--severity-info-bg);
    border-color: var(--severity-info);
}

.finding-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.finding-severity {
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.finding-card.critical .finding-severity { background: var(--severity-critical); color: var(--text-primary); }
.finding-card.warning .finding-severity { background: var(--severity-warning); color: #000; }
.finding-card.info .finding-severity { background: var(--severity-info); color: var(--text-primary); }

.finding-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-heading);
}

.finding-description {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.finding-values {
    display: flex;
    gap: 1rem;
    margin-top: 0.4rem;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.finding-values span { font-weight: 600; color: var(--text-secondary); }

/* --- Recommendations --- */
.rec-card {
    padding: 0.9rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

.rec-card:hover {
    border-color: var(--border-input);
    transform: translateY(-1px);
}

.rec-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.rec-priority {
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-primary);
}

.rec-priority.immediate { background: var(--priority-immediate); }
.rec-priority.high { background: var(--priority-high); color: #000; }
.rec-priority.medium { background: var(--priority-medium); }
.rec-priority.low { background: var(--priority-low); }

.rec-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-heading);
}

.rec-explanation {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 0.5rem;
}

.rec-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.rec-action-tag {
    padding: 0.15rem 0.5rem;
    background: var(--accent-glow);
    border-radius: 999px;
    font-size: 0.68rem;
    color: var(--accent);
    font-weight: 500;
}

/* --- Assumptions --- */
.assumption-card {
    padding: 0.6rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
}

.assumption-code {
    font-weight: 600;
    color: var(--cyan);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.assumption-desc { color: var(--text-secondary); margin-top: 0.15rem; }
.assumption-impact { color: var(--text-muted); font-size: 0.72rem; margin-top: 0.1rem; }

/* --- Responsive --- */
@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .panel-input {
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        max-height: 50vh;
    }
    .panel-results { min-height: 50vh; }
}

@media (max-width: 600px) {
    .app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}
    .panel-input, .panel-results { padding: 0.75rem; }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .field-row { grid-template-columns: 1fr; }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--accent-glow);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Sidebar --- */
.sidebar {
    width: 280px;
    min-width: 280px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow-y: auto;
}
.sidebar.collapsed { transform: translateX(-280px); }
.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}
.sidebar-toggle {
    position: fixed;
    left: 280px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 101;
    border-radius: 0 50% 50% 0;
    padding: 10px 5px;
    transition: left 0.3s ease;
}
.sidebar.collapsed ~ .sidebar-toggle {
    left: 0;
}
body {
    transition: padding-left 0.3s ease;
    padding-left: 280px;
}
body.sidebar-closed {
    padding-left: 0;
}

/* Design Item Card */
.design-item {
    padding: 0.7rem;
    border-bottom: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
    background: var(--bg-card);
}
.design-item:hover { background: var(--bg-card); }
.design-item.active { border-left: 3px solid var(--accent); background: var(--bg-card); }
.design-header { display: flex; justify-content: space-between; align-items: center; }
.design-title { font-weight: 600; font-size: 0.85rem; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.design-meta { font-size: 0.72rem; color: var(--text-muted); display: flex; gap: 0.3rem; flex-wrap: wrap; }
.design-meta span { background: var(--bg-card); padding: 0.1rem 0.3rem; border-radius: 4px; border: 1px solid var(--border-subtle); }
.design-actions { display: flex; gap: 0.3rem; align-items: center; }
.btn-fav { cursor: pointer; color: var(--text-muted); background: none; border: none; font-size: 1.1rem; transition: color 0.2s; }
.btn-fav.active { color: var(--severity-warning); }
.btn-del { cursor: pointer; color: var(--severity-critical); background: none; border: none; font-size: 1rem; opacity: 0.6; transition: opacity 0.2s; }
.btn-del:hover { opacity: 1; }
.sidebar-empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); font-size: 0.85rem; line-height: 1.5; }

/* Compare Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.88); z-index: 200; display: flex; align-items: center; justify-content: center;}
.modal { width: 100%; max-width: 700px; max-height: 90vh; overflow-y: auto; background: var(--bg-card); border-radius: var(--radius-md); border: 1px solid var(--border-subtle); padding: 1.5rem; box-shadow: var(--shadow-card), var(--shadow-glow); }

.compare-table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.85rem; }
.compare-table th, .compare-table td { padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--border-subtle); text-align: left; }
.compare-table th { color: var(--text-secondary); font-weight: 600; background: var(--bg-card-hover); }
.compare-better { color: var(--conf-high); font-weight: bold; }
.compare-worse { color: var(--severity-critical); font-weight: bold; }
.compare-neutral { color: var(--text-muted); }

.summary-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

.results-content > * {
    animation: fadeIn 0.4s ease forwards;
}

.results-content > :nth-child(2) { animation-delay: 0.05s; }
.results-content > :nth-child(3) { animation-delay: 0.1s; }
.results-content > :nth-child(4) { animation-delay: 0.15s; }
.results-content > :nth-child(5) { animation-delay: 0.2s; }
.results-content > :nth-child(6) { animation-delay: 0.25s; }
.results-content > :nth-child(7) { animation-delay: 0.3s; }
.results-content > :nth-child(8) { animation-delay: 0.35s; }
.results-content > :nth-child(9) { animation-delay: 0.4s; }
.results-content > :nth-child(10) { animation-delay: 0.45s; }
.results-content > :nth-child(11) { animation-delay: 0.5s; }
.results-content > :nth-child(12) { animation-delay: 0.55s; }

/* Error toast */
.error-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.8rem 1.2rem;
    background: var(--severity-critical-bg);
    border: 1px solid var(--severity-critical);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    max-width: 400px;
    z-index: 999;
    animation: fadeIn 0.3s ease;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.error-toast-title {
    font-weight: 700;
    color: var(--severity-critical);
    margin-bottom: 0.3rem;
}

/* --- Evidence Grade --- */
.evidence-grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    border: 2px solid;
}
.evidence-grade-badge.grade-A { background: var(--bg-card); color: var(--conf-high); border-color: var(--conf-high); }
.evidence-grade-badge.grade-B { background: var(--bg-card); color: var(--cyan); border-color: var(--cyan); }
.evidence-grade-badge.grade-C { background: var(--bg-card); color: var(--severity-warning); border-color: var(--severity-warning); }
.evidence-grade-badge.grade-D { background: var(--bg-card); color: var(--severity-critical); border-color: var(--severity-critical); }

.evidence-dimensions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.evidence-dim-card {
    padding: 0.6rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    border-left: 3px solid;
}
.evidence-dim-card.grade-A { border-left-color: var(--conf-high); }
.evidence-dim-card.grade-B { border-left-color: var(--cyan); }
.evidence-dim-card.grade-C { border-left-color: var(--severity-warning); }
.evidence-dim-card.grade-D { border-left-color: var(--severity-critical); }

.dim-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.2rem;
}

.dim-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dim-grade {
    font-size: 0.75rem;
    font-weight: 800;
}
.dim-grade.grade-A { color: var(--conf-high); }
.dim-grade.grade-B { color: var(--cyan); }
.dim-grade.grade-C { color: var(--severity-warning); }
.dim-grade.grade-D { color: var(--severity-critical); }

.dim-reason {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* --- Trace Cards --- */
.trace-card {
    padding: 0.7rem 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
}

.trace-metric {
    font-weight: 700;
    color: var(--cyan);
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
}

.trace-formula {
    font-family: 'Courier New', monospace;
    font-size: 0.72rem;
    color: var(--accent);
    background: var(--bg-card);
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.3rem;
    display: inline-block;
}

.trace-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.3rem;
}

.trace-input-tag {
    padding: 0.1rem 0.4rem;
    background: var(--bg-card);
    border-radius: 4px;
    font-size: 0.68rem;
    color: var(--text-secondary);
}

.trace-result {
    font-weight: 700;
    color: var(--text-heading);
    font-size: 0.85rem;
    margin-top: 0.3rem;
}

/* Pinout & Wiring */
.badge.cw { background: var(--bg-card); color: var(--color-primary); border: 1px solid rgba(59, 130, 246, 0.2); }
.badge.ccw { background: var(--bg-card); color: #d97706; border: 1px solid rgba(245, 158, 11, 0.2); }
.pinout-card { background: var(--surface); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 1rem; }
.pinout-card h4 { margin-bottom: 0.5rem; color: var(--text); }

/* ── Component Entry Rows ── */
.component-entry {
    background: var(--surface, rgba(255,255,255,0.03));
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    position: relative;
}
.component-entry .field-row { margin-bottom: 4px; }
.btn-remove-comp {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--bg-card);
    border: 1px solid rgba(239,68,68,0.3);
    color: #ef4444;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-remove-comp:hover { background: var(--bg-card); }

/* ── Data Tables ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 12px;
}
.data-table th {
    background: var(--bg-card);
    color: var(--accent);
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid rgba(124,58,237,0.3);
}
.data-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}
.data-table tr:hover td { background: var(--bg-card-hover); }
.data-table .good { color: #22c55e; }
.data-table .warn { color: #f59e0b; }
.data-table .bad { color: #ef4444; }

/* TomSelect Dark Theme Overrides */
.ts-control {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 0.5rem 0.65rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}
.ts-control > input {
    color: var(--text-primary);
}
.ts-dropdown {
    background: #1e1e2e !important;
    border: 1px solid var(--border-focus);
    border-radius: 8px;
    color: var(--text-primary);
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    margin-top: 4px;
    z-index: 9999;
    max-height: 320px;
    overflow-y: auto;
    backdrop-filter: none;
    opacity: 1;
}
.ts-dropdown .option {
    padding: 10px 14px;
    font-size: 0.92rem;
    line-height: 1.5;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #1e1e2e !important;
}
.ts-dropdown .option:last-child {
    border-bottom: none;
}
.ts-dropdown .option:hover, .ts-dropdown .active {
    background: #2d2d44 !important;
    color: var(--accent);
}
.ts-dropdown .optgroup-header {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-color);
}

/* --- Mobile Tab Bar --- */
.mobile-tab-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    z-index: 1000;
    padding: 0.5rem;
}

.mobile-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.mobile-tab.active {
    background: var(--bg-card);
    color: var(--accent);
}

/* --- Results Sticky Nav Bar --- */
.results-nav-bar {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    z-index: 10;
    padding: 0.75rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
}

.results-nav-bar::-webkit-scrollbar { height: 0px; }

.results-nav-bar .nav-btn {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.results-nav-bar .nav-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

@media (max-width: 900px) {
    .mobile-tab-bar {
        display: flex;
    }
    .panel-input {
        max-height: none;
        padding-bottom: 80px; /* Space for tabs */
    }
    .panel-results {
        padding-bottom: 80px;
        display: none; /* Handled by JS */
    }
    .panel-input.active, .panel-results.active {
        display: block;
    }
    /* Default app layout shows both, we need to hide one based on tabs */
    .app-layout {
        display: block;
    }
}


/* --- Tom Select Dark Theme Overrides --- */
.ts-control {
    background-color: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid var(--border-subtle) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
}

.ts-control input {
    color: var(--text-primary) !important;
}

.ts-dropdown {
    background-color: var(--bg-surface-elevated) !important;
    border: 1px solid var(--border-subtle) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
}

.ts-dropdown .option {
    color: var(--text-secondary);
}

.ts-dropdown .option.active,
.ts-dropdown .option:hover {
    background-color: var(--accent) !important;
    color: #fff !important;
}

.ts-dropdown .optgroup-header {
    background-color: rgba(0,0,0,0.3) !important;
    color: var(--text-muted) !important;
    font-weight: bold;
}



/* --- Theme Transition Animations --- */
html[data-theme] *, html[data-theme] *::before, html[data-theme] *::after {
    transition-property: background-color, color, border-color, box-shadow, fill, stroke !important;
    transition-duration: 0.4s !important;
    transition-timing-function: ease !important;
}


/* --- Ana Buton Yazilarini Daima Beyaz Tut --- */
.btn-primary, .btn-primary:hover {
    color: #ffffff !important;
}


/* ── PRICING MODAL ── */
.pricing-modal-content {
    max-width: 900px;
    background: #0f172a;
    border: 1px solid rgba(124, 58, 237, 0.3);
    text-align: center;
    padding: 40px;
}
.pricing-title {
    font-size: 2rem;
    color: #fff;
    margin-bottom: 10px;
}
.pricing-subtitle {
    color: #94a3b8;
    margin-bottom: 40px;
}
.pricing-cards {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: stretch;
}
.pricing-card {
    flex: 1;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.3s ease, border-color 0.3s ease;
}
.pricing-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.2);
}
.pricing-card h3 {
    font-size: 1.2rem;
    color: #e2e8f0;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.pricing-card .price {
    font-size: 2.5rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 30px;
}
.pricing-card .price span {
    font-size: 1rem;
    color: #94a3b8;
    font-weight: 400;
}
.pricing-card .features {
    list-style: none;
    padding: 0;
    margin: 0 0 30px 0;
    text-align: left;
    flex-grow: 1;
}
.pricing-card .features li {
    font-size: 0.9rem;
    color: #cbd5e1;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.pricing-card .features li i {
    color: #10b981; /* Green check */
    margin-top: 3px;
}
.pricing-card .features li.disabled {
    color: #475569;
}
.pricing-card .features li.disabled i {
    color: #475569;
}
.pricing-card button {
    width: 100%;
    margin-top: auto;
}

/* PRO Card Highlights */
.pro-card {
    background: linear-gradient(180deg, rgba(124,58,237,0.1) 0%, rgba(0,0,0,0) 100%);
    border-color: var(--accent-color);
}
.pro-card:hover {
    border-color: #8b5cf6;
}
.popular-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-color);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Business Card */
.business-card {
    border-color: rgba(245, 158, 11, 0.3);
}
.business-card h3 {
    color: #f59e0b;
}
.btn-secondary {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
    cursor: not-allowed;
}
