/* ==========================================================================
   AgriVision AI - Design Tokens & Core Styles
   ========================================================================== */

:root {
    --bg-primary: #0a0f18;
    --bg-secondary: #111927;
    --bg-tertiary: #1b263b;
    --card-bg: rgba(17, 25, 39, 0.75);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-hover: rgba(255, 255, 255, 0.12);

    --emerald-50: #ecfdf5;
    --emerald-100: #d1fae5;
    --emerald-400: #34d399;
    --emerald-500: #10b981;
    --emerald-600: #059669;
    --emerald-700: #047857;
    --emerald-glow: rgba(16, 185, 129, 0.35);

    --amber-400: #fbbf24;
    --amber-500: #f59e0b;
    --rose-500: #f43f5e;
    --rose-600: #e11d48;
    --rose-glow: rgba(244, 63, 94, 0.35);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --shadow-subtle: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 35px -5px var(--emerald-glow);
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Ambient Glows */
.ambient-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(140px);
    pointer-events: none;
    z-index: 0;
    opacity: 0.25;
}
.glow-1 {
    top: -100px;
    left: 10%;
    background: radial-gradient(circle, #059669, transparent 70%);
}
.glow-2 {
    top: 300px;
    right: 5%;
    background: radial-gradient(circle, #0284c7, transparent 70%);
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 15, 24, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--card-border);
    padding: 0.9rem 0;
}

.nav-container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--emerald-500), #0284c7);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.35rem;
    box-shadow: 0 4px 14px var(--emerald-glow);
}

.brand-title {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #fff;
    display: block;
}

.accent-text {
    background: linear-gradient(135deg, var(--emerald-400), #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-subtitle {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    display: block;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--emerald-400);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--emerald-400);
    box-shadow: 0 0 10px var(--emerald-400);
    animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition-fast);
}

.nav-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--card-hover);
    transform: translateY(-1px);
}

.api-btn {
    background: rgba(56, 189, 248, 0.1);
    border-color: rgba(56, 189, 248, 0.25);
    color: #38bdf8;
}
.api-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: rgba(56, 189, 248, 0.5);
}

/* ==========================================================================
   Hero Section
   ========================================================================== */

.main-container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
    position: relative;
    z-index: 1;
}

.hero-section {
    text-align: center;
    max-width: 860px;
    margin: 0 auto 3rem;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 1rem;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 999px;
    color: var(--emerald-400);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 1.2rem;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.03em;
    color: #fff;
    margin-bottom: 1rem;
}

.hero-desc {
    font-size: 1.05rem;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 2rem;
}

.stats-ribbon {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.2rem;
    margin-top: 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-md);
    padding: 1.1rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    transition: var(--transition-smooth);
}

.stat-card:hover {
    border-color: rgba(16, 185, 129, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.4);
}

.stat-icon {
    font-size: 1.5rem;
    color: var(--emerald-400);
    width: 40px;
    height: 40px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-data {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.stat-num {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
}

.stat-label {
    font-size: 0.73rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ==========================================================================
   Workspace Layout Grid
   ========================================================================== */

.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 1.8rem;
    align-items: start;
}

.panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-subtle);
    position: relative;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.4rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--card-border);
}

.panel-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.panel-hint {
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    border: 1px solid var(--card-border);
}

/* Input Tab Switcher */
.tab-pills {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-secondary);
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.2rem;
}

.tab-pill {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 0.8rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.tab-pill.active {
    background: var(--emerald-600);
    color: #fff;
    box-shadow: 0 2px 10px var(--emerald-glow);
}

.tab-pill:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Dropzone */
.dropzone {
    border: 2px dashed rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.03);
    border-radius: var(--radius-md);
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--emerald-400);
    background: rgba(16, 185, 129, 0.08);
    transform: scale(1.01);
}

.upload-icon-circle {
    width: 68px;
    height: 68px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 50%;
    margin: 0 auto 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--emerald-400);
    font-size: 1.8rem;
}

.drop-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.4rem;
}

.drop-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 1.4rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.7rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--emerald-500), var(--emerald-600));
    color: #fff;
    box-shadow: 0 4px 14px var(--emerald-glow);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--emerald-400), var(--emerald-500));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--emerald-glow);
}

.btn-emerald {
    background: linear-gradient(135deg, #10b981, #047857);
    color: #fff;
    box-shadow: 0 4px 16px var(--emerald-glow);
    width: 100%;
    padding: 0.9rem 1.5rem;
    font-size: 1rem;
}
.btn-emerald:hover {
    background: linear-gradient(135deg, #34d399, #059669);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Camera Stream Container */
.camera-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

#camera-feed {
    width: 100%;
    height: 280px;
    background: #000;
    border-radius: var(--radius-md);
    object-fit: cover;
    border: 1px solid var(--card-border);
}

.camera-controls {
    display: flex;
    gap: 0.8rem;
    width: 100%;
}
.camera-controls button {
    flex: 1;
}

/* Sample Images Gallery */
.sample-intro {
    font-size: 0.83rem;
    color: var(--text-secondary);
    margin-bottom: 0.9rem;
}

.sample-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.sample-card {
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: left;
}

.sample-card:hover {
    border-color: var(--emerald-400);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.sample-img-wrap {
    width: 100%;
    height: 85px;
    background: #1e293b;
    overflow: hidden;
    position: relative;
}

.sample-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.sample-card:hover .sample-img-wrap img {
    transform: scale(1.08);
}

.sample-title {
    padding: 0.45rem 0.6rem;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Preview Studio */
.preview-container {
    margin-top: 1.2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--card-border);
}

.preview-wrapper {
    position: relative;
    width: 100%;
    height: 240px;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--card-border);
}

.preview-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.btn-clear {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}
.btn-clear:hover {
    background: var(--rose-600);
}

.preview-actions {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.file-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 15, 24, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: var(--radius-lg);
}

.spinner-container {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.2rem;
}

.radar-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--emerald-400);
    animation: radar-grow 1.6s infinite cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes radar-grow {
    0% { transform: scale(0.4); opacity: 1; }
    100% { transform: scale(1.6); opacity: 0; }
}

.loading-icon {
    font-size: 2rem;
    color: var(--emerald-400);
    animation: spin-leaf 3s linear infinite;
}

@keyframes spin-leaf {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.3rem;
}
.loading-subtext {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   Results Panel Styles
   ========================================================================== */

.report-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.7rem;
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 999px;
}

.empty-results {
    padding: 4.5rem 2rem;
    text-align: center;
}

.empty-icon-wrap {
    width: 76px;
    height: 76px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 50%;
    margin: 0 auto 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 2rem;
}

.empty-results h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.6rem;
}

.empty-results p {
    font-size: 0.9rem;
    color: var(--text-muted);
    max-width: 440px;
    margin: 0 auto;
}

/* Active Diagnosis Content */
.results-content {
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
}

.diagnosis-card {
    background: linear-gradient(145deg, rgba(16, 185, 129, 0.08), rgba(2, 132, 199, 0.06));
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: var(--radius-md);
    padding: 1.4rem;
    box-shadow: 0 0 25px -5px var(--emerald-glow);
}

.diagnosis-card.infected {
    background: linear-gradient(145deg, rgba(244, 63, 94, 0.1), rgba(245, 158, 11, 0.06));
    border-color: rgba(244, 63, 94, 0.4);
    box-shadow: 0 0 25px -5px var(--rose-glow);
}

.diagnosis-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.2rem;
}

.crop-category {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.diagnosis-title {
    font-size: 1.55rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-indicator.healthy {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid var(--emerald-400);
    color: var(--emerald-400);
}

.status-indicator.infected {
    background: rgba(244, 63, 94, 0.2);
    border: 1px solid var(--rose-500);
    color: var(--rose-500);
}

.confidence-box {
    margin-bottom: 1.2rem;
}

.conf-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.conf-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.conf-val {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
}

.meter-bar-track {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.meter-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--emerald-400), #38bdf8);
    border-radius: 999px;
    transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.diagnosis-card.infected .meter-bar-fill {
    background: linear-gradient(90deg, var(--amber-400), var(--rose-500));
}

.quick-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.meta-key {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.meta-value {
    font-size: 0.88rem;
    font-weight: 700;
    color: #fff;
}

.severity-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
    font-size: 0.75rem;
    width: fit-content;
}
.severity-high, .severity-critical {
    background: rgba(244, 63, 94, 0.2);
    color: var(--rose-500);
}
.severity-medium {
    background: rgba(245, 158, 11, 0.2);
    color: var(--amber-400);
}
.severity-none, .severity-low {
    background: rgba(16, 185, 129, 0.2);
    color: var(--emerald-400);
}

/* Top K Ranking Card */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.3rem;
}

.card h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topk-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.topk-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.topk-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
}

.topk-name {
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.topk-rank {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.topk-pct {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--emerald-400);
}

.topk-bar-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 999px;
    overflow: hidden;
}

.topk-bar-fill {
    height: 100%;
    background: var(--emerald-500);
    border-radius: 999px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Treatment Sections */
.treatment-card {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.treatment-section {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.1rem;
}

.treatment-heading {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.45rem;
}

.symptoms-head { color: #38bdf8; }
.organic-head { color: var(--emerald-400); }
.chemical-head { color: var(--amber-400); }
.prevention-head { color: #a78bfa; }

.treatment-body {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ==========================================================================
   Encyclopedia Modal
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 15, 0.85);
    backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal-window {
    background: var(--bg-primary);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 960px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

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

.modal-title-group {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.modal-icon {
    font-size: 1.6rem;
    color: var(--emerald-400);
}

.modal-title-group h3 {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
}

.modal-title-group p {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.modal-close {
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.modal-close:hover {
    color: #fff;
    background: var(--rose-600);
}

.modal-search-bar {
    padding: 1rem 1.7rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--card-border);
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background: var(--bg-primary);
    border: 1px solid var(--card-border);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
}

.search-input-wrap i {
    color: var(--text-muted);
}

.search-input-wrap input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 0.88rem;
    font-family: inherit;
}

.filter-pills {
    display: flex;
    gap: 0.4rem;
}

.filter-pill {
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.filter-pill.active {
    background: var(--emerald-600);
    border-color: var(--emerald-500);
    color: #fff;
}

.modal-body {
    padding: 1.5rem 1.7rem;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.encyclopedia-card {
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    transition: var(--transition-fast);
}

.encyclopedia-card:hover {
    border-color: var(--emerald-400);
    transform: translateY(-1px);
}

.enc-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.4rem;
}

.enc-plant {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--emerald-400);
}

.enc-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
}

.enc-status {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.enc-status.healthy {
    background: rgba(16, 185, 129, 0.15);
    color: var(--emerald-400);
}

.enc-status.infected {
    background: rgba(244, 63, 94, 0.15);
    color: var(--rose-500);
}

.enc-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 0.4rem;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.8rem 1.2rem;
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: toast-in 0.3s ease forwards;
}

.toast.error {
    border-color: var(--rose-500);
    background: rgba(244, 63, 94, 0.15);
}

.toast.success {
    border-color: var(--emerald-400);
    background: rgba(16, 185, 129, 0.15);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
    border-top: 1px solid var(--card-border);
    background: var(--bg-secondary);
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footer-sub {
    font-size: 0.75rem;
    margin-top: 0.2rem;
}

.footer-right {
    display: flex;
    gap: 1.5rem;
}

.footer-right a {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition-fast);
}

.footer-right a:hover {
    color: var(--emerald-400);
}

/* ==========================================================================
   Utility & Responsiveness
   ========================================================================== */

.hidden {
    display: none !important;
}

@media (max-width: 1024px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
    .stats-ribbon {
        grid-template-columns: repeat(2, 1fr);
    }
    .modal-body {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .hero-title {
        font-size: 1.8rem;
    }
    .stats-ribbon {
        grid-template-columns: 1fr;
    }
    .sample-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .quick-meta-grid {
        grid-template-columns: 1fr;
    }
    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}


/* ==========================================================================
   Grad-CAM Explainability Section
   ========================================================================== */

.gradcam-card {
    border: 1px solid rgba(99, 179, 237, 0.2);
    background: linear-gradient(135deg,
        rgba(17, 25, 39, 0.9) 0%,
        rgba(15, 23, 42, 0.95) 100%);
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.5s ease forwards;
}

.gradcam-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg,
        #3b82f6 0%,
        #06b6d4 40%,
        #10b981 70%,
        #f59e0b 100%);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.gradcam-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.gradcam-title-group {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
}

.gradcam-icon {
    font-size: 1.5rem;
    color: #60a5fa;
    margin-top: 2px;
    filter: drop-shadow(0 0 8px rgba(96, 165, 250, 0.5));
}

.gradcam-card h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.25rem;
}

.gradcam-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
}

.gradcam-subtitle code {
    background: rgba(96, 165, 250, 0.12);
    color: #60a5fa;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.73rem;
}

.gradcam-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(96, 165, 250, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(96, 165, 250, 0.25);
    white-space: nowrap;
    flex-shrink: 0;
}

.gradcam-status-badge.success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--emerald-400);
    border-color: rgba(16, 185, 129, 0.3);
}

.gradcam-status-badge.error {
    background: rgba(244, 63, 94, 0.12);
    color: #f87171;
    border-color: rgba(244, 63, 94, 0.25);
}

/* ── Error notice ─────────────────────────────────────────────────────────── */

.gradcam-error-notice {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.65rem 1rem;
    color: #fca5a5;
    font-size: 0.82rem;
    margin-bottom: 1rem;
}

/* ── Three-image grid ─────────────────────────────────────────────────────── */

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

.gradcam-img-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform var(--transition-fast),
                border-color var(--transition-fast),
                box-shadow var(--transition-fast);
}

.gradcam-img-card:hover {
    transform: translateY(-2px);
    border-color: rgba(96, 165, 250, 0.3);
    box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.4);
}

.gradcam-img-label {
    font-size: 0.73rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.gradcam-img-label.heatmap-label {
    color: #fb923c;
}

.gradcam-img-label.overlay-label {
    color: var(--emerald-400);
}

.gradcam-img-wrap {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gradcam-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--transition-smooth);
}

.gradcam-img-card:hover .gradcam-img {
    transform: scale(1.03);
}

/* ── Jet colormap legend ──────────────────────────────────────────────────── */

.gradcam-legend {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    padding: 0.65rem 1rem;
    font-size: 0.75rem;
}

.legend-label {
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.legend-gradient {
    flex: 1;
    min-width: 80px;
    max-width: 180px;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(90deg,
        #00008b 0%,
        #0000ff 12%,
        #00ffff 25%,
        #00ff00 37%,
        #ffff00 50%,
        #ffa500 62%,
        #ff0000 75%,
        #8b0000 100%);
    border: 1px solid rgba(255,255,255,0.1);
}

.legend-low {
    color: #60a5fa;
    font-weight: 600;
    font-size: 0.7rem;
}

.legend-high {
    color: #f87171;
    font-weight: 600;
    font-size: 0.7rem;
}

.legend-hint {
    color: var(--text-muted);
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex: 1;
    min-width: 200px;
}

.legend-hint i {
    color: #60a5fa;
    flex-shrink: 0;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .gradcam-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .gradcam-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .gradcam-grid {
        gap: 0.75rem;
    }
    .legend-hint {
        display: none;
    }
}

/* Encyclopedia Layout Update */
.encyclopedia-layout { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 1.5rem !important; height: 60vh; overflow: hidden !important; padding: 1.5rem; }
.encyclopedia-sidebar { overflow-y: auto; padding-right: 0.5rem; display: flex; flex-direction: column; gap: 1rem; }
.encyclopedia-detail { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-md); padding: 1.5rem; overflow-y: auto; }
.enc-detail-title { font-size: 1.3rem; color: #fff; margin-bottom: 1rem; border-bottom: 1px solid var(--card-border); padding-bottom: 0.5rem; }
.enc-section { margin-bottom: 1.2rem; }
.enc-section h5 { color: var(--emerald-400); margin-bottom: 0.4rem; font-size: 0.95rem; }
.enc-section p { font-size: 0.85rem; color: var(--text-secondary); }
@media (max-width: 768px) { .encyclopedia-layout { grid-template-columns: 1fr !important; overflow-y: auto !important; height: 75vh; } .encyclopedia-sidebar { overflow-y: visible; } }
