:root {
    --bg-color: #f1f2f6;
    --card-bg: #ffffff;
    --text-color: #333333;
    --price-color: #2ecc71;
    --buy-color: #2ecc71;
    --sell-color: #e74c3c;
    --disabled-color: #f1f2f6;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding-bottom: 50px;
}

.header {
    background-color: var(--card-bg);
    padding: 30px;
    text-align: center;
    margin-top: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* Reinforced styling so the image can never blow up the page */
header img, 
.profile-pic {
    width: 120px !important;
    height: 120px !important;
    max-width: 100%;
    border-radius: 50% !important;
    object-fit: cover !important;
    margin-bottom: 15px !important;
    display: inline-block;
}

h1 {
    margin: 0;
    font-size: 32px;
}

.balance-bar {
    background: linear-gradient(180deg, #2ecc71, #27ae60);
    color: white;
    text-align: center;
    font-size: 36px;
    font-weight: bold;
    padding: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    border-radius: 8px;
    transition: background 0.3s;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.item-card {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.item-image {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    background-color: #eee;
}

.item-name {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 10px;
}

.item-price {
    font-size: 18px;
    color: var(--price-color);
    font-weight: bold;
    margin-bottom: 15px;
}

.item-actions-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 10px;
    margin-top: auto;
}

.qty-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.qty-row label {
    font-size: 14px;
    font-weight: bold;
    color: #666;
}

.qty-input {
    width: 80px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    text-align: center;
    font-family: inherit;
}

.qty-input:focus {
    outline: none;
    border-color: var(--buy-color);
}

.item-controls {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    user-select: none;
    flex: 1;
}

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

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

.btn-sell {
    background-color: var(--disabled-color);
    color: #333;
    margin-right: 10px;
}

.btn-sell.active {
    background-color: var(--sell-color);
    color: white;
}

.btn-buy {
    background-color: var(--buy-color);
    color: white;
    margin-left: 10px;
}

.item-count {
    font-size: 18px;
    font-weight: bold;
    width: 60px;
    text-align: center;
    color: #333;
}

.receipt-section {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    text-align: center;
    display: none;
}

.receipt-section h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 28px;
}

.receipt-item {
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.receipt-item-name {
    flex: 1;
    text-align: left;
}

.receipt-item-count {
    width: 80px;
    text-align: center;
}

.receipt-item-price {
    flex: 1;
    text-align: right;
    color: var(--price-color);
    font-weight: bold;
}

.receipt-total {
    display: flex;
    justify-content: space-between;
    font-size: 24px;
    font-weight: bold;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #333;
}

.total-spent-amount {
    color: var(--price-color);
}

@media (max-width: 768px) {
    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
    }
    .balance-bar {
        font-size: 28px;
        top: -1px;
    }
    .app-container {
        padding: 10px;
    }
}