body {
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #e3f2fd 0%, #f8fafc 100%);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}
.main-header {
    background: #23272b;
    color: #fff;
    box-shadow: 0 2px 8px rgba(33,150,243,0.08);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    z-index: var(--z-header) !important;
    position: relative !important;
}
/* Ensure the header children (header-content and nav) sit on one row when space permits */
.main-header {
    padding: 0 24px;
}
.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: none;
    margin: 0;
    padding: 0 24px;
    min-height: 64px;
}
/* Left group inside header (hamburger + logo) */
.header-content > .left-group,
    .header-content > div[style] {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Utility classes to replace inline styles */
.hamburger-btn {
    background: none;
    border: none;
    padding: 0;
    margin-right: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
}
.hamburger-icon { height: 2em; width: 2em; filter: drop-shadow(0 0 2px #222); }
.site-logo { height: 56px !important; width: auto !important; max-height:56px !important; display: block; flex-shrink: 0; }

/* Calendar styling overrides */
.fc .fc-toolbar { background: transparent; padding: 12px 8px; }
.fc .fc-toolbar-title { font-size: 1.1rem; color: #fff; font-weight:600 }
.fc .fc-daygrid-event { border-radius:6px; padding:4px 6px; font-size:0.95rem }
.fc .fc-daygrid-event-dot { display:none }
.fc .fc-event { box-shadow: none }
.fc .fc-daygrid-day-frame { padding: 6px }
.fc .fc-daygrid-day-top { font-size:0.9rem }
.fc .fc-scrollgrid-section-liquid { background: transparent }

/* Visual hint for long multi-day events */
.fc .fc-event { border-left: 4px solid rgba(255,255,255,0.15) }

/* Job modal styles (fallback to inline styles in JS; these are extras) */
#job-modal-overlay input, #job-modal-overlay textarea { font-family: inherit }

/* Ensure header logo does not scale down/up unexpectedly on responsive breakpoints */
.header-content .left-group .site-logo { height: 56px !important; max-height:56px !important; width: auto !important; }

/* Hide legacy/isolation-injected hamburger button (artifact) — use responsive menu instead */
#isolated-hamburger { display: none !important; }

/* Node controls panel (was inline-styled in custom-flashings.html) */
.node-controls-panel {
    position: absolute;
    right: 12px;
    top: 12px;
    width: 220px;
    max-height: 80vh;
    overflow: auto;
    z-index: 40;
    background: rgba(255,255,255,0.95);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.06);
    display: none;
}

/* mobile bottom toolbar */
.mobile-bottom-toolbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 56px;
    display: none;
    background: #fff;
    border-top: 1px solid #eee;
    box-shadow: 0 -6px 20px rgba(0,0,0,0.06);
    z-index: 4000;
    align-items: center;
    justify-content: space-around;
}
.mobile-bottom-toolbar .mb-btn {
    background: none;
    border: none;
    padding: 6px 12px;
    font-size: 0.95rem;
}

@media (max-width: 900px) {
    .mobile-bottom-toolbar { display: flex; }
}

#hamburger-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    margin-right: 8px;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: none !important;
    border: none !important;
    padding: 15px !important;
    margin-right: 16px !important;
    z-index: var(--z-menu-button) !important;
    position: relative !important;
    min-width: 44px !important;
    min-height: 44px !important;
}
.site-title {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #fff;
}
.login-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    /* match nav link sizing so Login lines up with other menu items */
    font-size: 1.05rem;
    padding: 10px 16px;
    border-radius: 6px;
    transition: background 0.2s;
}
.login-btn:hover {
    background: #fff;
    color: #1976d2;
}
/* If you want the nav bar to also be dark grey, uncomment below: */
.main-nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    background: #23272b;
    box-shadow: 0 2px 8px rgba(33,150,243,0.04);
    padding: 0 24px;
    margin-left: auto;
    border-radius: 0 0 12px 12px;
}
/* Make nav links white for contrast on dark background */
.main-nav a {
    color: #fff;
    text-decoration: none;
    margin: 0 6px;
    font-weight: 500;
    padding: 10px 16px 10px 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    font-size: 1.05rem;
    line-height: 1.2; /* keep consistent vertical rhythm */
    transition: background 0.2s, color 0.2s;
}
.main-nav a:hover {
    background: #1976d2;
    color: #fff;
}

/* Prevent layout shift when toggling the nav/overlay by keeping scrollbar space stable */
html {
    overflow-y: scroll;
    scrollbar-gutter: stable;
}

/* Focus styles that don't change layout (no outline affecting box model) */
.main-nav a:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(25,118,210,0.14);
}
.nav-icon {
    height: 1.2em;
    width: 1.2em;
    margin-right: 7px;
    vertical-align: middle;
    filter: drop-shadow(0 0 2px #222);
}
.shop-item-add-btn:hover {
    background: linear-gradient(90deg, #388e3c 60%, #43a047 100%);
    box-shadow: 0 4px 16px rgba(67,160,71,0.16);
    transform: scale(1.04);
}

/* shop item card look for category listings */
.shop-item {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
    margin: 12px;
    max-width: 320px;
    display: inline-block;
    vertical-align: top;
}
.shop-item img { max-width: 100%; border-radius: 8px; }
.shop-item h3 { margin: 8px 0 6px 0; }

/* Product detail inline control rows */
.product-detail-card { max-width: 720px; margin: 0 auto; }
.product-detail-controls { display:flex; flex-direction:column; gap:12px; width:100%; }
.field-row { display:flex; align-items:center; gap:12px; }
.field-row label { min-width: 80px; font-weight:600; }
.field-row .inline-control { display:flex; align-items:center; gap:8px; }

/* colour swatches to the right */
.swatch-list { display:flex; gap:8px; align-items:center; margin-left:12px; flex-wrap:wrap; max-width: calc(5 * 36px + 4 * 8px); }
.swatch { width:28px; height:28px; border-radius:50%; border:2px solid #ddd; cursor:pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.08); flex: 0 0 28px; }
.swatch.selected { outline: 3px solid #1976d2; }

/* Page container with curved rectangle (matches Custom Flashings container) */
.page-container {
    max-width: 720px;
    margin: 36px auto;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(33,150,243,0.08);
    padding: 28px 24px;
}

@media (max-width: 900px) {
    .shop-item { max-width: 95%; display:block; }
    .field-row { flex-direction:column; align-items:flex-start; }
    .field-row label { min-width: auto; }
}
/* Hamburger menu: hidden on desktop, shown by media query for small screens */
#hamburger-menu-btn {
    display: none; /* hide by default (desktop) */
    align-items: center;
    justify-content: center;
    z-index: 3001;
}

/* Page title moved into the header to sit inline with the logo/hamburger */
.header-content .page-title,
.header-content .page-title * {
    color: #fff;
}
.header-content .page-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    padding-left: 8px;
    display: block; /* always show current page title */
}
@media (max-width: 900px) {
    #hamburger-menu-btn { display: flex !important; }

    /* On small screens: hide the desktop nav by default, show when .open */
    .main-nav {
        display: none;
        position: absolute;
        left: 12px;
        top: 64px;
        z-index: 3002;
        flex-direction: column;
        gap: 6px;
        min-width: 200px;
        max-width: 320px;
        padding: 8px;
        background: #e9e9e9;
        border-radius: 6px;
        box-shadow: 0 8px 28px rgba(2,6,23,0.12);
    }
    .main-nav:not(.open) { display: none; }
    .main-nav.open { display: flex; }

    .main-nav.open a { display: block; color: #0b2a4a; text-decoration: none; padding: 8px 10px; font-weight: 600; border-radius: 2px; }
    .main-nav.open a + a { margin-top: 4px; }
    .main-nav.open a:focus, .main-nav.open a:hover { background: rgba(11,42,74,0.06); outline: none; }

    /* overlay covers the rest of the screen to allow click-outside */
    #nav-overlay { display: none; }
    .main-nav.open ~ #nav-overlay { display: block; position: fixed; inset: 0; background: transparent; z-index: 2999; }

    /* Temporary: hide floating login button on mobile while debugging hamburger */
    .login-btn { display: none !important; }
}
/* Ensure readable link colours for the two mobile nav presentations:
   - compact dropdown: dark text on light panel
   - fullscreen drawer (.is-mobile): white text on dark background
*/
@media (max-width:900px) {
    .main-nav.open a { color: #0b2a4a !important; }
}
.is-mobile nav.open a { color: #fff !important; }
nav.open ~ #nav-overlay {
  display: block;
}
/* Control body scrolling when nav is open and overlay is active */
html.nav-open, body.nav-open {
    overflow: hidden !important;
}

/* Ensure overlay covers viewport and is visible when nav has .open */
#nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 2999;
}
.main-nav.open ~ #nav-overlay {
    display: block;
}
header {
  position: relative;
  z-index: 2003;
}
@media (min-width: 901px) {
    nav {
        left: 0;
        top: 128px; /* match taller header */
    }
}

/* Strong, defensive header sizing for desktop to avoid page-specific CSS changing the height */
@media (min-width: 901px) {
    .main-header {
    height: 128px !important;
    min-height: 128px !important;
    box-sizing: border-box;
    overflow: visible; /* allow nav to be visible if it would otherwise wrap */
    flex-wrap: nowrap; /* keep logo, title and nav on single line */
    }
    .header-content {
        height: 128px !important;
        min-height: 128px !important;
        align-items: center;
    }
    /* Keep a stable reserved space on the right for the profile widget to avoid nav jumps */
    :root { --profile-space: 250px; }
    .main-nav {
        height: 128px !important;
        min-height: 128px !important;
        align-items: center;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        /* Lock to a stable pixel value on desktop; JS can still update --profile-space if needed
           but we avoid layout jank by using a fixed margin-right as the primary rule. */
        margin-right: 250px !important;
        transition: margin-right 160ms ease; /* smooth any small changes */
    }
    .main-nav a {
        padding: 0 12px !important;
        height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }
    .header-content .page-title { font-size: 1.8rem !important; }
    /* scale logo and hamburger images to fit the taller header */
    .header-content img[alt="Metal Shop Logo"] {
        height: 8.8em !important; /* roughly double the previous 4.4em */
        width: auto !important;
        display: block !important;
    }
    #hamburger-menu-btn img {
        height: 4em !important; /* double the 2em size */
        width: auto !important;
    }
}

/* end of header/nav media rules */

@media (max-width: 600px) {
    header {
        padding: 16px 0 10px 0;
    }
    nav {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }
    nav a {
        margin: 4px 0;
        padding: 10px 0;
        border-radius: 0;
        font-size: 1.08rem;
    }
    .shop-item {
        width: 92vw;
        min-width: 0;
        margin: 12px 0;
        padding: 16px 6vw 14px 6vw;
    }
    .shop-item img {
        max-width: 90vw;
    }
    .shop-item button {
        width: 100%;
        font-size: 1.1rem;
        padding: 14px 0;
    }
    main, section {
        padding: 0 2vw;
    }
    footer {
        font-size: 1rem;
        padding: 14px 0 10px 0;
    }
}
/* Global styles */

body {
    background: linear-gradient(135deg, #e3f2fd 0%, #f8fafc 100%);
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Reserve space on the right for the floating cart when present. JS will set --floating-cart-space */
/* floating cart removed; body padding reverted to normal */

/* Cart item and thumbnail styles */
.cart-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid #eee;
    background: #fff;
    border-radius: 8px;
    margin-bottom: 10px;
}
.cart-thumb {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #ddd;
}
.cart-meta { font-size: 0.92rem; color: #444; margin-top:4px; }


/* Node label styles */
.node-label {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.9rem;
    position: absolute;
    z-index: 20;
    pointer-events: auto; /* Allow interaction */
}
.node-label-group {
    position: absolute;
    display: flex;
    align-items: center;
    z-index: 20;
    pointer-events: auto;
    background: rgba(255,255,255,0.97);
    padding: 2px 2px 2px 0;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    flex-direction: row; /* Ensure horizontal layout */
}
.node-label-input {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 2px 6px;

/* floating cart removed */
    font-size: 0.9rem;
    width: 60px;
    margin-right: 4px;
}

/* Mobile-first utility: when JS detects a mobile user add class .is-mobile to <html> */
.is-mobile body { font-size: 17px; }
.is-mobile .main-nav a { font-size: 1.12rem; padding: 14px 16px; }
.is-mobile .canvas-controls .btn { padding: 12px 14px; font-size: 1.06rem; border-radius: 10px; }
.is-mobile .btn { min-height: 44px; }
.is-mobile input[type='number'], .is-mobile input, .is-mobile select, .is-mobile button { font-size: 1rem; }
.is-mobile .shop-item { padding: 18px; margin: 12px; }
.is-mobile .page-container, .is-mobile .container { margin: 12px; padding: 14px; }
.is-mobile .node-label-group { font-size: 1rem; }
.is-mobile .node-label-input { min-width: 56px; padding: 8px 10px; }
.is-mobile #node-controls { right: 8px; top: 8px; left: auto; width: calc(100% - 16px); max-height: 40vh; }
.is-mobile #flashing-summary { max-width: 100%; padding: 14px; font-size: 1.05rem; }

/* Make nav touch targets larger and ensure overlay covers viewport */
.is-mobile #nav-overlay { display: none; }
.is-mobile nav.open { position: fixed; left: 0; top: 0; width: 100%; height: 100%; background: #222; z-index: 4000; padding-top: 64px; overflow-y: auto; }
.is-mobile nav.open a { display: block; padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.04); }

/* Improve forms and inline controls on small screens */
@media (max-width: 520px) {
    .is-mobile .node-label-group { left: 8px !important; right: 8px !important; }
}

/* Fluid images and product layout improvements */
img { max-width: 100%; height: auto; display: block; }
.product-detail img, .shop-item img { max-width: 100%; height: auto; }

/* Make inputs and numeric controls easier to tap on mobile */
input, select, textarea, button { box-sizing: border-box; }
.is-mobile input, .is-mobile select, .is-mobile textarea { font-size: 1rem; }
.is-mobile input[type='number'] { width: 100%; min-height: 44px; padding: 8px 10px; }
.is-mobile .product-detail-controls .field-row label { min-width: 28px; }

/* Compact header for mobile: reduce logo, hide profile widget to save space */
.is-mobile .header-content img[alt="Metal Shop Logo"] { height: 3.2em !important; }
.is-mobile .profile-widget { display: none !important; }

/* Buttons primary actions full width in product/cart on small screens */
@media (max-width: 720px) {
    .is-mobile .product-detail .btn, .is-mobile .shop-item button, .is-mobile #checkout-btn { width: 100%; }
}

/* Header utility classes to replace inline styles */
.header-left { display:flex; align-items:center; }
.hamburger-btn { background:none; border:none; padding:0; margin-right:16px; cursor:pointer; display:flex; align-items:center; }
.hamburger-btn img { height:2em; width:2em; filter: drop-shadow(0 0 2px #222); }
.site-logo { height:4.4em; width:auto; display:block; }

/* Make mobile nav vertical and avoid horizontal scrolling */
nav.main-nav { display:flex; flex-direction:row; }
.is-mobile nav.main-nav { flex-direction: column; align-items: stretch; padding: 0; }
.is-mobile nav.main-nav a { white-space: normal; }

/* Bottom mobile toolbar */
.mobile-bottom-toolbar { position: fixed; left: 0; right: 0; bottom: 0; height: 56px; background: rgba(255,255,255,0.98); box-shadow: 0 -6px 18px rgba(0,0,0,0.12); display: flex; gap: 8px; align-items: center; justify-content: space-around; padding: 6px 12px; z-index: 5000; border-top: 1px solid #eee; }
.mobile-bottom-toolbar button { background: none; border: none; display:flex; flex-direction:column; align-items:center; justify-content:center; font-size: 12px; color: #222; }
.mobile-bottom-toolbar button .icon { font-size: 20px; margin-bottom: 4px; }
.mobile-bottom-toolbar.hidden { display: none; }

/* Make main nav items easier to tap on larger phones */
@media (max-width: 900px) {
    .main-nav a { padding: 12px 16px; }
}
.node-label-btn {
    background: #28a745;
    border: none;
    border-radius: 50%;
    color: #fff;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    margin-left: 2px;
}

/* Fix header height on desktop so pages look consistent when navigating */
@media (min-width: 901px) {
    .main-header {
        box-sizing: border-box;
        height: 64px; /* fixed header height */
        padding: 0 24px;
    }
    .header-content {
        height: 64px;
        align-items: center;
    }
    .main-nav {
        height: 64px;
        align-items: center;
    }
    }
.node-label-btn.angle {
    background: #ff9800;
}
.node-label-btn:active {
    filter: brightness(0.9);
}
.node-label-group.angle {
    border: 1.5px dashed #ff9800;
}
.node-label-input.angle {
    border-color: #ff9800;
    color: #ff9800;
}

/* Canvas styles */
canvas {
    border: 1px solid #ccc;
    background: #fff;
    display: block;
    margin: 1rem auto;
}

/* Summary styles */
#summary {
    background: #f1f1f1;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    margin-top: 1rem;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-item {
    margin: 0 1rem;
}

.btn-primary {
    background: #007bff;
    color: #fff;
    border: none;
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-outline-secondary {
    background: transparent;
    color: #333;
    border: 1px solid #ccc;
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn-outline-secondary:hover {
    background: #f8f9fa;
}

/* Edit mode styles */
.edit-mode .node-label {
    display: none;
}
.edit-mode .node-label-input {
    display: inline-block;
}
.edit-mode .node-label-btn {
    display: inline-block;
}
.edit-mode #summary {
    display: none;
}

/* Tapered lines styles */
.tapered-line {
    stroke: #ff9800;
    stroke-width: 4;
    fill: none;
}

.tapered-line-label {
    fill: #ff9800;
    font-weight: bold;
    font-size: 16px;
    text-anchor: middle;
    dominant-baseline: middle;
}

/* Navigation styles */


/* Shop item styles */

.shop-item {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(33,150,243,0.10);
    padding: 22px 18px 18px 18px;
    margin: 22px 14px;
    display: inline-block;
    vertical-align: top;
    width: 250px;
    text-align: center;
    transition: box-shadow 0.2s, transform 0.2s;
    position: relative;
}
.shop-item:hover {
    box-shadow: 0 8px 32px rgba(33,150,243,0.18);
    transform: translateY(-4px) scale(1.03);
}
.shop-item img {
    max-width: 100%;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(33,150,243,0.07);
}
.shop-item .price {
    color: #1976d2;
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 8px;
    display: block;
}
.shop-item button {
    background: linear-gradient(90deg, #43a047 60%, #66bb6a 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 22px;
    margin-top: 12px;
    cursor: pointer;
    font-size: 1.08rem;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(67,160,71,0.08);
    transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
}
.shop-item button:hover {
    background: linear-gradient(90deg, #388e3c 60%, #43a047 100%);
    box-shadow: 0 4px 16px rgba(67,160,71,0.16);
    transform: scale(1.04);
}

/* Footer styles */

footer {
    background: linear-gradient(90deg, #e3f2fd 60%, #bbdefb 100%);
    color: #333;
    text-align: center;
    padding: 20px 0 18px 0;
    margin-top: 40px;
    font-size: 1.08rem;
    box-shadow: 0 -2px 8px rgba(33,150,243,0.04);
}

/* Add these styles */
.tier-info {
    margin: 20px 0;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 4px;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #ddd;
    border-radius: 10px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-fill {
    height: 100%;
    background: #4CAF50;
    transition: width 0.3s ease;
}

.profile-widget {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.profile-widget .user-info {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.profile-widget .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #1976d2;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    font-weight: bold;
}

/* Cart rendered inside the profile widget */
.profile-widget { overflow: visible; }

.xp-bar {
    width: 200px;
    height: 12px;
    background: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    margin: 5px 0;
}

.xp-bar .progress {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.3s ease;
}

.tier-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    background: #1976d2;
    color: white;
    font-size: 0.8em;
    margin-left: 5px;
}

/* Improved header responsive behavior */
@media (min-width: 901px) {
    .main-header {
        /* Keep existing styles */
    }
    .main-nav {
        display: flex !important;
    }
    #hamburger-menu-btn {
        /* Hide hamburger on desktop */
        display: none !important;
    }
}

@media (max-width: 900px) {
    .main-nav {
        /* Hide nav by default on mobile */
        display: none !important;
    }
    .main-nav.open {
        /* Show nav when open class is applied */
        display: flex !important;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        background: #23272b;
        z-index: 3002;
        padding: 60px 0 20px 0;
        box-shadow: 0 0 15px rgba(0,0,0,0.3);
        overflow-y: auto;
    }
    #hamburger-menu-btn {
        /* Always show hamburger on mobile */
        display: flex !important;
        z-index: 3003;
    }
    #nav-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 3001;
    }
}

/* Enhanced floating cart button styles */
.floating-cart-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #1976d2;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.2s, background-color 0.2s;
}

.floating-cart-btn:hover {
    transform: scale(1.05);
    background: #1565c0;
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.cart-icon {
    width: 28px;
    height: 28px;
}

/* Enhanced floating cart badge styles */
.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f44336;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 2px solid white;
    transition: transform 0.2s ease-in-out;
}

.cart-badge:empty {
    display: none;
}

.floating-cart-btn:hover .cart-badge {
    transform: scale(1.1);
}

/* Improved mobile menu styles */
@media (min-width: 901px) {
    .main-header {
        height: 128px !important;
        min-height: 128px !important;
        box-sizing: border-box;
        overflow: visible;
        flex-wrap: nowrap;
    }
    .main-nav {
        display: flex !important;
        flex-direction: row !important;
        position: static !important;
        width: auto !important;
        height: 128px !important;
        min-height: 128px !important;
        background: #23272b;
        box-shadow: none;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }
    #hamburger-menu-btn {
        display: none !important;
    }
}

@media (max-width: 900px) {
    .main-header {
        height: 64px !important;
        min-height: 64px !important;
    }
    .header-content {
        height: 64px !important;
        min-height: 64px !important;
    }
    
    /* Fixed styles for mobile navigation */
    .main-nav {
        display: none !important;
        flex-direction: column !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 280px !important;
        height: 100vh !important;
        background: #23272b !important;
        z-index: 3002 !important;
        padding: 70px 0 20px 0 !important;
        box-shadow: 0 0 20px rgba(0,0,0,0.5) !important;
        overflow-y: auto !important;
        transform: translateX(-100%) !important; /* Hide off-screen by default */
        transition: transform 0.3s ease-in-out !important;
    }
    
    /* Show menu when open class is applied */
    .main-nav.open {
        display: flex !important;
        transform: translateX(0) !important;
    }
    
    /* Style nav links for mobile */
    .main-nav a {
        padding: 15px 20px !important;
        margin: 0 !important;
        border-radius: 0 !important;
        font-size: 1.1rem !important;
        border-bottom: 1px solid rgba(255,255,255,0.1) !important;
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .main-nav a:hover, 
    .main-nav a:focus {
        background-color: #1976d2 !important;
        color: white !important;
    }
    
    /* Always show hamburger on mobile */
    #hamburger-menu-btn {
        display: flex !important;
        z-index: 3003 !important;
        cursor: pointer !important;
    }
    
    /* Overlay styles */
    #nav-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 3001;
    }
}

/* ULTRA-MINIMAL MENU STYLES */
@media (max-width: 900px) {
  /* Remove ALL animations and transitions */
  .main-nav, .main-nav *, #nav-overlay {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
  
  .main-nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: #23272b;
    z-index: 9995;
    padding: 70px 0 20px 0;
    overflow-y: auto;
    flex-direction: column;
  }
  
  #hamburger-menu-btn {
    cursor: pointer;
    z-index: 9999;
    position: relative;
  }
  
  #hamburger-menu-btn * {
    pointer-events: none;
  }
  
  #nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9990;
    cursor: pointer;
  }
}

/* Cleanup any debug elements */
.debug-btn,
#menu-debug-logger,
.hamburger-js-loaded::before,
#hamburger-menu-btn::before,
#hamburger-menu-btn::after {
  display: none !important;
}
}

/* Remove all debugging elements */
#menu-debug-logger,
.test-hamburger-btn,
#emergency-hamburger,
.debug-indicator,
.menu-toggle-btn {
  display: none !important;
}
}

/* Clean up by removing ALL other hamburger-related styles */
.hamburger-js-loaded #hamburger-menu-btn::after,
.hamburger-js-loaded::before,
#hamburger-menu-btn::before,
#hamburger-menu-btn::after,
.animating,
#menu-debug-logger,
.menu-toggle-btn,
#emergency-hamburger,
#debug-toggle-btn {
  display: none !important;
}
    z-index: 3003;
    position: relative;
}

#hamburger-menu-btn img, 
#hamburger-menu-btn svg {
    pointer-events: none; /* Make sure clicks go to the button */
}
    #nav-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background: rgba(0,0,0,0.5) !important;
        z-index: 3001 !important;
        display: none !important;
        cursor: pointer !important;
    }
    
    #nav-overlay.active {
        display: block !important;
    }
}

/* CRITICAL FIX: Better menu transition styles */
@media (max-width: 900px) {
    .main-nav {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 280px !important;
        height: 100vh !important;
        background: #23272b !important;
        z-index: 3002 !important;
        padding: 70px 0 20px 0 !important;
        box-shadow: 0 0 20px rgba(0,0,0,0.5) !important;
        overflow-y: auto !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease-in-out !important;
        flex-direction: column !important;
    }
    
    .main-nav.open {
        display: flex !important;
        transform: translateX(0) !important;
    }
    
    /* Overlay styles */
    #nav-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background: rgba(0,0,0,0.5) !important;
        z-index: 3001 !important;
        display: none !important;
        cursor: pointer !important;
    }
}

/* Extra force on the hamburger button to make it super clickable */
#hamburger-menu-btn {
    cursor: pointer !important;
    position: relative !important;
    z-index: 4000 !important; /* Higher than anything else */
    background: transparent !important;
    border: none !important;
    outline: none !important;
    padding: 15px !important; /* Larger tap target */
    margin-right: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 48px !important; 
    min-height: 48px !important;
}

/* Make the button's click area visibly larger for debugging */
#hamburger-menu-btn::before {
    content: "";
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    pointer-events: none;
}

/* Z-INDEX CRITICAL FIX: Define a clear z-index stacking context for the entire site */
:root {
    --z-modal: 9999;      /* Highest: modal dialogs, critical UI */
    --z-menu-button: 9998; /* Menu button above all */
    --z-menu: 9997;       /* Mobile menu panel */
    --z-overlay: 9996;    /* Overlay behind menu */
    --z-header: 9995;     /* Header */
    --z-normal: 1;        /* Normal content */
}

/* Fix the header z-index */
.main-header {
    z-index: var(--z-header) !important;
    position: relative !important;
}

/* CRITICAL Z-INDEX FIXES FOR MOBILE MENU */
@media (max-width: 900px) {
    /* Core mobile nav styles - highest specificity with corrected z-index */
    .main-nav {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 280px !important;
        height: 100vh !important;
        background: #23272b !important;
        z-index: var(--z-menu) !important;
        padding: 70px 0 20px 0 !important;
        box-shadow: 0 0 20px rgba(0,0,0,0.5) !important;
        overflow-y: auto !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease-out !important;
        flex-direction: column !important;
    }
    
    /* Show menu when open class is applied */
    .main-nav.open {
        display: flex !important;
        transform: translateX(0) !important;
    }
    
    /* Always visible hamburger button with higher z-index */
    #hamburger-menu-btn {
        cursor: pointer !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: none !important;
        border: none !important;
        padding: 15px !important;
        margin-right: 16px !important;
        z-index: var(--z-menu-button) !important;
        position: relative !important;
        min-width: 44px !important;
        min-height: 44px !important;
    }
    
    /* Overlay with correct z-index */
    #nav-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background: rgba(0,0,0,0.5) !important;
        z-index: var(--z-overlay) !important;
        display: none !important;
        cursor: pointer !important;
    }
    
    #nav-overlay.active {
        display: block !important;
    }
}

/* Remove any existing debugging visual indicators that might be causing issues */
.hamburger-js-loaded #hamburger-menu-btn::after {
    display: none !important;
}

.hamburger-js-loaded::before {
    display: none !important;
}

/* Force higher tap target */
#hamburger-menu-btn {
    min-width: 50px !important;
    min-height: 50px !important;
    width: 50px !important;
    height: 50px !important;
    touch-action: manipulation !important;
}

/* Disable pointer events on the hamburger icon to ensure the button itself gets all clicks */
#hamburger-menu-btn img,
#hamburger-menu-btn svg {
    pointer-events: none !important;
}

/* Animation state helper class */
.animating {
    pointer-events: none !important;
}

/* Fix header element click issues */
.main-header {
    position: relative !important;
    z-index: var(--z-header) !important;
}

/* Block suspicious clicks with an invisible shield */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    background: transparent;
    z-index: 10001;
    pointer-events: none;
}

/* Improve responsiveness of mobile menu transition */
@media (max-width: 900px) {
    .main-nav {
        /* Make animation faster */
        transition: transform 0.2s ease-in-out !important; /* Reduced from 0.3s to 0.2s */
    }
    
    #nav-overlay {
        /* Instant overlay appearance */
        transition: opacity 0.15s ease-out !important;
    }
    
    /* Prioritize transforms for better performance */
    .main-nav, #nav-overlay {
        will-change: transform, opacity !important;
        backface-visibility: hidden !important;
        -webkit-backface-visibility: hidden !important;
        transform-style: preserve-3d !important;
        perspective: 1000px !important;
    }
}

/* CRITICAL: Super responsive menu animation */
@media (max-width: 900px) {
    .main-nav {
        /* Even faster animation */
        transition: transform 0.18s cubic-bezier(0,0,0.2,1) !important;
        will-change: transform !important;
    }
    
    /* Force hardware acceleration for smoother animations */
    .main-nav, #nav-overlay {
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
    }
    
    /* Improve hamburger button feedback */
    #hamburger-menu-btn {
        transition: transform 0.08s ease-out !important;
    }
    
    #hamburger-menu-btn:active {
        transform: scale(0.92) !important;
    }
}

/* GUARANTEED MENU STYLES - These override everything */
@media (max-width: 900px) {
  /* Remove ALL animations and transitions */
  .main-nav, 
  .main-nav *,
  #nav-overlay {
    transition: none !important;
    animation: none !important;
    transform: none !important;
    will-change: auto !important;
  }
  
  /* Navigation styling with !important on everything */
  .main-nav {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 280px !important;
    height: 100vh !important;
    background-color: #23272b !important;
    color: white !important;
    z-index: 9999 !important;
    padding-top: 70px !important;
    overflow-y: auto !important;
    box-shadow: 0 0 20px rgba(0,0,0,0.5) !important;
    flex-direction: column !important;
  }
  
  /* Links inside the menu */
  .main-nav a {
    display: block !important;
    padding: 15px 25px !important;
    color: white !important;
    text-decoration: none !important;
    font-size: 16px !important;
    margin: 0 !important;
    border-bottom: 1px solid #444 !important;
  }
  
  /* Links hover state */
  .main-nav a:hover {
    background-color: #444 !important;
  }
  
  /* Button styling */
  #hamburger-menu-btn {
    cursor: pointer !important;
    z-index: 10000 !important;
    position: relative !important;
  }
  
  /* Overlay styling */
  #nav-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0,0,0,0.5) !important;
    z-index: 9998 !important;
  }
  
  /* Emergency button styling */
  #emergency-hamburger {
    position: fixed !important;
    bottom: 20px !important;
    left: 20px !important;
    z-index: 10001 !important;
    background-color: #f44336 !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 50px !important;
    height: 50px !important;
    font-size: 24px !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3) !important;
    cursor: pointer !important;
    padding: 0 !important;
  }
}

/* CRITICAL: Force hamburger to stay at top-left on mobile (all pages) */
@media (max-width: 900px) {
    #isolated-hamburger {
        position: fixed !important;
        top: 9px !important;
        left: 16px !important;
        z-index: 10001 !important;
        width: 44px !important;
        height: 44px !important;
        background: transparent !important;
        border: none !important;
        cursor: pointer !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    #isolated-hamburger img {
        width: 32px !important;
        height: 32px !important;
    }
    
    /* Ensure .left-group doesn't add extra spacing */
    .main-header .left-group {
        position: relative !important;
        padding-left: 0 !important;
        margin-left: 0 !important;
    }
}

/* Standard Flashings Grid Layout - FIXED */
.standard-flashings-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
    gap: 20px !important;
    padding: 20px 0 !important;
}

/* CRITICAL: Subcategory Section Styling - Force Visible Separation */
.subcategory-section {
    width: 100% !important;
    margin-bottom: 60px !important;
    padding-top: 40px !important;
    padding-bottom: 20px !important;
    border-top: 4px solid #1976d2 !important;
    clear: both !important;
    page-break-inside: avoid !important;
}

.subcategory-section:first-child {
    border-top: none !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.subcategory-title {
    color: #1976d2 !important;
    margin: 0 0 28px 0 !important;
    padding: 16px 0 12px 0 !important;
    font-size: 2rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
    border-bottom: 3px solid #1976d2 !important;
    display: block !important;
}

/* CRITICAL FIX: Ensure grid is inside subcategory and not floated */
.standard-flashings-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
    gap: 20px !important;
    padding: 20px 0 !important;
    width: 100% !important;
    clear: both !important;
    float: none !important;
}

/* Ensure shop items don't float */
.standard-flashings-grid .shop-item {
    display: flex !important;
    flex-direction: column !important;
    margin: 0 !important;
    max-width: none !important;
    width: auto !important;
    float: none !important;
    clear: both !important;
}
