:root {
    --agri-green: #10b981;
    --agri-dark: #064e3b;
    --agri-bg: #f0fdf4;
    --text-main: #1f2937;
    --text-light: #6b7280;
    --white: #ffffff;
    --danger: #ef4444;
    --radius: 16px;
}

/* 1. GLOBAL RESET */
body {
    background-color: var(--agri-bg);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
    color: var(--text-main);
}

.agri-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: 100vh; /* Ensures full height background */
}

/* 2. HEADER SECTION */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px; /* More space below title */
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--agri-dark);
    display: flex;
    align-items: center;
    gap: 12px;
}

.count-badge {
    background: #dcfce7;
    color: var(--agri-dark);
    font-size: 14px;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
}

/* NEW: Header Actions Group */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* NEW: Back Button (Ghost Pill Style) */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: 50px;
    color: var(--text-light);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-back:hover {
    border-color: var(--agri-green);
    color: var(--agri-green);
    background-color: #f0fdf4;
    transform: translateX(-3px);
}

/* 3. THE GRID (The Fix) */
.crop-grid {
    display: grid !important; /* Force Grid Mode */

    /* PC: Exactly 3 Columns */
    grid-template-columns: repeat(3, 1fr);

    /* GAP: 40px space between all tiles */
    gap: 40px !important;

    width: 100%;
    padding-bottom: 60px;
}

/* 4. CARD DESIGN */
.crop-card {
    background: white;
    border-radius: var(--radius);
    padding: 30px; /* More internal breathing room */
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 1px solid rgba(229, 231, 235, 0.5);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    height: 100%;
    box-sizing: border-box; /* Ensures padding doesn't break width */
}

.crop-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    border-color: var(--agri-green);
    z-index: 10; /* Bring to front on hover */
}

/* Top Green Bar decoration */
.crop-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 6px;
    background: linear-gradient(90deg, var(--agri-dark), var(--agri-green));
    opacity: 0; transition: opacity 0.3s;
}
.crop-card:hover::before { opacity: 1; }

/* Image Area */
.icon-wrapper {
    width: 90px; height: 90px; border-radius: 50%;
    padding: 4px; background: white; border: 2px solid #f3f4f6;
    margin-bottom: 20px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.crop-icon { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* Content */
.card-content { flex-grow: 1; width: 100%; margin-bottom: 24px; }
.crop-name { font-size: 22px; font-weight: 700; color: var(--text-main); margin: 0 0 8px 0; }
.crop-desc { font-size: 14px; color: var(--text-light); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* NEW: Unit Badge */
.unit-badge {
    display: inline-block;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 600;
    margin-bottom: 12px;
    border: 1px solid #e5e7eb;
}

/* Buttons */
.card-actions { display: flex; gap: 12px; width: 100%; margin-top: auto; padding-top: 20px; border-top: 1px solid #f3f4f6; }
.action-btn { flex: 1; padding: 10px; border-radius: 10px; font-size: 14px; font-weight: 600; text-decoration: none; display: flex; align-items: center; justify-content: center; gap: 6px; transition: background 0.2s; border: none; cursor: pointer; }
.btn-edit { background: #f0fdf4; color: var(--agri-dark); }
.btn-edit:hover { background: #dcfce7; }
.btn-delete { background: #fef2f2; color: var(--danger); }
.btn-delete:hover { background: #fee2e2; }

/* 5. ADD NEW CARD */
.add-card { border: 2px dashed #cbd5e1; background: rgba(255,255,255,0.6); justify-content: center; box-shadow: none; min-height: 350px; }
.add-card:hover { border-color: var(--agri-green); background: white; transform: translateY(-4px); }
.add-circle { width: 70px; height: 70px; border-radius: 50%; background: #f0fdf4; color: var(--agri-green); display: flex; align-items: center; justify-content: center; font-size: 36px; margin-bottom: 16px; transition: all 0.3s; }
.add-card:hover .add-circle { background: var(--agri-green); color: white; transform: scale(1.1); }
.add-text { font-weight: 700; color: var(--text-light); font-size: 18px; }

/* 6. FORM STYLES */
.form-card {
    background: white; padding: 40px; border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05); border: 1px solid #f3f4f6; margin-top: 20px;
}
.form-group { margin-bottom: 24px; }
.filter-label { display: block; font-size: 13px; font-weight: 700; text-transform: uppercase; color: var(--text-light); margin-bottom: 8px; letter-spacing: 0.5px; }
.modern-input { width: 100%; padding: 14px 16px; border: 2px solid #e5e7eb; border-radius: 12px; font-size: 15px; color: var(--text-main); background: #f9fafb; transition: all 0.2s; box-sizing: border-box; font-family: inherit; }
.modern-input:focus { background: white; border-color: var(--agri-green); outline: none; box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1); }
.btn-submit { background: var(--agri-dark); color: white; width: 100%; padding: 16px; border: none; border-radius: 12px; font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.2s; display: flex; justify-content: center; align-items: center; gap: 8px; }
.btn-submit:hover { background: var(--agri-green); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3); }
.error-banner { background: #fef2f2; border: 1px solid #fca5a5; color: #b91c1c; padding: 16px; border-radius: 12px; margin-bottom: 24px; font-size: 14px; }
.flash-message { background: #ecfdf5; border-left: 4px solid var(--agri-green); color: #064e3b; padding: 16px; margin-bottom: 24px; border-radius: 8px; display: flex; align-items: center; gap: 12px; font-weight: 500; }

/* 7. RESPONSIVENESS */
@media (max-width: 900px) {
    /* Tablet: 2 Columns */
    .crop-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
}

@media (max-width: 600px) {
    /* Mobile: 1 Column */
    .crop-grid { grid-template-columns: 1fr; gap: 20px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .header-actions { width: 100%; }
    .btn-back { width: 100%; justify-content: center; }
    .form-card { padding: 24px; }
}