/* --- Global Variables --- */
:root {
    --primary: #00a884;
    --primary-dark: #008f6f;
    --dark: #2c3e50;
    --bg-color: #f8fafc;
    --white: #ffffff;
    --border: #e2e8f0;
    --shadow: 0 4px 15px rgba(0,0,0,0.05);
    --radius: 12px;
}

/* --- Base Reset --- */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body { 
    font-family: 'Inter', system-ui, -apple-system, sans-serif; 
    background-color: var(--bg-color); 
    color: var(--dark); 
    line-height: 1.5;
    font-size: 16px; /* Best for mobile readability */
}

/* --- Header & Navigation --- */
header {
    background: var(--white);
    padding: 0.8rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
}

nav a {
    text-decoration: none;
    color: var(--dark);
    margin-left: 15px;
    font-weight: 600;
    font-size: 0.9rem;
}

/* --- Layout --- */
.container { 
    max-width: 1100px; 
    margin: 1.5rem auto; 
    padding: 0 15px; 
}

.card {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

/* --- Forms & Inputs --- */
label { display: block; margin-bottom: 8px; font-weight: 700; font-size: 0.85rem; color: #64748b; text-transform: uppercase; }

input, select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 1rem; /* Prevents iOS auto-zoom on focus */
    background: #fdfdfd;
}

/* --- BOM Designer Rows (The Critical Part) --- */
.bom-row { 
    display: grid; 
    grid-template-columns: 2.5fr 1fr 1fr 1fr 1.2fr 44px; /* Desktop */
    gap: 10px; 
    background: #fcfcfc; 
    padding: 15px; 
    border-radius: 10px; 
    margin-bottom: 12px;
    align-items: center;
    border: 1px solid var(--border);
}

.bom-row input, .bom-row select { margin-bottom: 0; }

.calc-box { 
    background: #f1f5f9; 
    padding: 10px; 
    border-radius: 6px; 
    font-weight: 800; 
    text-align: right; 
    color: var(--dark);
    border: 1px inset var(--border);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    text-decoration: none;
}

.btn:active { transform: scale(0.98); }

.delete-btn {
    background: #fee2e2;
    color: #ef4444;
    border: 1px solid #fecaca;
    height: 44px;
    width: 44px;
    border-radius: 8px;
    cursor: pointer;
}

/* --- Total Section --- */
.total-section {
    margin-top: 20px;
    background: #f8fafc;
    padding: 20px;
    border-radius: var(--radius);
    border-top: 4px solid var(--primary);
    display: flex;
    justify-content: flex-end;
    gap: 30px;
}

.total-group { text-align: right; }
.total-value { font-size: 1.4rem; font-weight: 800; display: block; }
.total-value.gst { color: var(--primary); font-size: 1.8rem; }

/* --- MOBILE OPTIMIZATION (Media Query) --- */
@media (max-width: 768px) {
    header { flex-direction: column; gap: 15px; padding: 1rem; }
    nav { width: 100%; display: flex; justify-content: space-around; }
    nav a { margin: 0; font-size: 0.8rem; }

    /* Stack the BOM Designer items on mobile */
    .bom-row {
        grid-template-columns: 1fr 1fr; /* 2 items per row on mobile */
        gap: 8px;
    }

    /* Make Material selection span the full top row */
    .bom-row select:first-child {
        grid-column: span 2;
    }

    /* Make calculation and delete button share the bottom row */
    .calc-box { font-size: 1.1rem; }
    
    .total-section {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .total-group { text-align: center; }
    
    .btn { width: 100%; padding: 16px; } /* Larger tap target for fingers */
}