:root {
    --primary-color: #2e7d32;
    --accent-color: #f57c00;
    --bg-color: #f0f2f5;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 20px;
    color: #333;
}
button, a {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

.header {
    max-width: 1000px;
    margin: 0 auto 5px auto;
    background: white;
    padding: 10px 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);

    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #eee;
}

.troop_logo { 
    height: 40px; 
}

.header h2 { 
    color: var(--primary-color); 
    margin: 0; 
}

.main-container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    padding: 10px 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.headings { color: var(--accent-color); border-bottom: 2px solid #eee; padding-bottom: 10px; }

.btn-group { display: flex; gap: 15px; margin-top: 30px; }

.btn { background: var(--primary-color); color: white; padding: 12px 25px; 
    border: none; border-radius: 6px; cursor: pointer; font-weight: bold; 
    text-decoration: none; display: inline-block; font-size: 1rem;
    display: inline-block;
    box-sizing: border-box;
    vertical-align: middle;
}
.btn-confirm { background: var(--accent-color); color: white;}
.btn-back { background: #eee; color: #777; }
.btn-green { background: #2e7d32; }
.btn-orange { background: #f57c00; }
.btn-purple { background: #673ab7; }
.btn-logout { background: #d32f2f;}
.btn-remove { color: #d32f2f; text-decoration: none; font-weight: bold; font-size: 0.8rem; margin-left: 0px; }
.qty-input { width: 20px; padding: 5px; border: 1px solid #ccc; border-radius: 4px; }
.total-row { font-size: 1.1rem; font-weight: bold; text-align: right; color: var(--primary-color); }
table { width: 100%; border-collapse: collapse; margin-bottom: 5px; }
th { text-align: left; background: #f2f2f2; padding: 12px; }
td { padding: 12px; border-bottom: 1px solid #eee; }
.right-align { text-align: right; }

/* View Order Page */
.view-order-search-box { margin-bottom: 30px; }
.view-order-items { margin-top:10px; border-top: 1px dashed #ccc; padding-top: 10px; }
.view-order-item-row { display: flex; justify-content: space-between; font-size: 0.9rem; margin: 5px 0; color: #555; }
.error-message { color: #d32f2f; }

.order-card { background: white; padding: 20px; margin-bottom: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.order-header { display: flex; justify-content: space-between; border-bottom: 2px solid #eee; padding-bottom: 10px; margin-bottom: 15px; }

.item-table { width: 100%; border-collapse: collapse; margin: 15px 0; }
.item-table th { text-align: left; color: #666; font-size: 0.85rem; border-bottom: 1px solid #eee; padding-bottom: 5px; }
.item-table td { padding: 8px; border-bottom: 1px solid #fafafa; }


.status-badge { padding: 4px 8px; border-radius: 4px; font-size: 0.8rem; font-weight: bold; }
.status-paid { background: #e8f5e9; color: #2e7d32; }
.status-pending { background: #fff3e0; color: #ef6c00; }
.text-muted { color: #888; font-size: 0.85rem; }
.small-body { display: flex; justify-content: center; align-items: center; height: 100vh;}
.login-box { background: white; padding: 40px; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); text-align: center; }
button[name="mark_paid"], button[name="mark_unpaid"] {
    appearance: none;          /* Removes system-default styling */
    -webkit-appearance: none;   /* Specific fix for Safari/iOS */
    background-color: #ccc !important;
    border: 1px solid #ccc;
    padding: 3px 8px;
    border-radius: 2px;
    font-size: 0.75rem;
    cursor: pointer;
    color: inherit;
}
button[name="mark_paid"]:hover { background: #e8f5e9; }
button[name="mark_unpaid"]:hover { background: #ffebee; }    
.order-comments {
    margin: 10px 0; padding: 10px; 
    background: #fffde7; border-left: 4px solid #fdd835; 
    font-size: 0.9rem;
}

/* Form Styling */
.form-group { margin-bottom: 15px; }
label { display: block; font-weight: bold; margin-bottom: 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], select { 
    width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 6px; box-sizing: border-box; 
}

input[type="text"], 
input[type="password"], 
input[type="email"], 
input[type="tel"], 
input[type="number"], 
textarea, 
select {
    font-size: 16px !important;
}
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox */
input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}
.modal-overlay {
     position:fixed; z-index:10000; left:0; top:0; width:100%; height:100%; background:rgba(0,0,0,0.5);
}
.modal-content {
    background:white; width:250px; margin:15% auto; padding:20px; border-radius:10px; text-align:center; box-shadow:0 5px 15px rgba(0,0,0,0.3);
}
.modal-text {
    font-weight:bold; margin-bottom:30px; font-size: 1.1rem;
}
.modal-btn {
    padding:10px 20px; margin-right:10px; color:white; border:none; border-radius:5px; cursor:pointer;
}
.modal-btn-confirm { background:#d32f2f; }
.modal-btn-cancel { background:#666; }

.review-section { border-bottom: 1px solid #eee; padding: 15px 0; }
.review-label { font-weight: bold; color: #666; font-size: 1.1rem; }
.review-value { font-size: 1.1rem; margin-top: 5px; }

.cart-header {
    box-shadow: none;
    border-radius: 0px;
    padding: 5px;
    margin-bottom: 30px;
    text-align: right;
}
.fundraiser-info {
    text-align: center;
}

.sponsor-logo { height: 35px; vertical-align:middle;}
.cart-badge {
    transition: transform 0.2s ease;
    display: inline-block; /* Required for transform to work */
    background: var(--accent-color);
    color: white;
    padding: 12px 20px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: bold;
    display: inline;
    align-items: center;
}

/* Product Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
}

.product-card {
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    transition: transform 0.2s;
}
h3 {
    font-size: 1rem;
    color: #333;
}

.product-card:hover { transform: translateY(-5px); box-shadow: 0 5px 15px rgba(0,0,0,0.05); }

.product-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 15px;
}

.price { color: var(--primary-color); font-weight: bold; font-size: 1.2rem; display: block; margin: 10px 0; }

.btn-primary {
    padding: 7px 15px;
    cursor: pointer;
    font-weight: normal;
}

.footer-nav {
    margin-top: 50px;
    padding-top: 20px;
    padding-bottom: 20px;
    border-top: 1px solid #eee;    /* Top border line */
    border-bottom: 1px solid #eee; /* Bottom border line */
    text-align: center;
}

.footer-nav h3 {
    margin-top: 20px;
    font-size: 1.1rem;
    color: #444;
}

.footer-links {
    text-align: right; margin-bottom: 15px;
}

.credit-popup {
    position:fixed; bottom:20px; right:20px; background:#f7e700; padding:10px 20px; border-radius:30px; box-shadow:0 4px 10px rgba(0,0,0,0.2); z-index:9999;"
}
.paid-unpaid { display:inline; margin-left:10px; }

.mark-paid { background: #2e7d32; color: white; }
.mark-unpaid { background: #d32f2f; color: white;}
.nav-bar { margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center;  }
.tabbed { margin: 5px 0; }
.order-summary {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border: 1px dashed #ccc;
}
.large-emoji { font-size: 60px; }
.only-print { display: none !important; }
.venmo-logo { margin-top: 20px; width: 200px; border-radius: 8px; border: 1px solid #ddd; }

/* --- Leaderboard Container Fix --- */
.leaderboard-container {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap; /* Essential for mobile stacking */
}

.leaderboard-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    flex: 1 1 300px; /* Grow, Shrink, and a 300px base */
    min-width: 0; /* Prevents overflow in flexbox */
}

.scout-header { background: #f3e5f5; font-weight: bold; font-size: 1.1rem; }
.scout-header-tr { padding: 2px; border-top: 4px solid #C8B6F0; background: #C8B6F0; color: black; }
.status-paid { color: #2e7d32; font-weight: bold; }
.status-pending { color: #f57c00; font-weight: bold; }

/* --- Responsive Media Query --- */
.rank { font-weight: bold; color: #673ab7; margin-right: 10px; }
.scout-name { flex-grow: 1; }
.sales-amount { font-weight: bold; color: #2e7d32; }        


@media (max-width: 800px) {
    body { padding: 10px; }
    .main-container { padding: 20px; }
    .header { padding: 0px 15px; }
    .header h2 { font-size: 1.2rem;}
    td, th { padding: 8px; font-size: 0.9rem; }
    .grid { grid-template-columns: 1fr; }
    .product-card img {
        height: 150px;
        object-fit: cover;
        border-radius: 6px;
        margin-bottom: 15px;
    }
    .order-summary { padding: 2px; }
    .leaderboard-card {
        flex: 1 1 100%; /* Take full width on small screens */
    }

    .leader-row {
        font-size: 0.85rem; /* Shrink text slightly to fit names */
    }
    
    /* Hide some detail on mobile leaderboard to save space */
    .leader-row span[style*="color: #888"] {
        display: none; 
    }
}

/* This CSS only triggers when the user hits 'Print' */
@media print {
    /* Remove background colors/shadows to save ink */
    body {
        background: white !important;
        padding: 0;
    }
    .no-print {
        display: none !important;
    }

    .only-print {
        display: block !important;
    }


    /* Prevent the Scout name from being the last thing on a page */
    .scout-header + tr {
        break-before: avoid;
    }

    .scout-header-tr { 
        background: #eee !important; /* Light grey is better for printers than dark purple */
        color: black !important; 
        font-size: 1.4rem; /* Make the name bigger for easy sorting */
        padding: 10px !important;
    }    
}