/* RESTORED: Your exact design tokens and CSS variables */
:root { 
    --bg: #f4f5f7; 
    --sb: #fff; 
    --hd: #1e293b; 
    --hv: #f1f5f9; 
    --ac: #e0f2fe; 
    --txt: #333; 
    --mt: #64748b; 
    --fl: #475569; 
    --tac: #0369a1; 
    --brd: #e2e8f0; 
    --btn: #334155; 
    --touch-target: 40px;
    --sidebar-width: 350px;
}

[data-theme="dark"] { 
    --bg: #0f172a; 
    --sb: #1e293b; 
    --hd: #0f172a; 
    --hv: #334155; 
    --ac: #0369a1; 
    --txt: #f8fafc; 
    --mt: #94a3b8; 
    --fl: #cbd5e1; 
    --tac: #fff; 
    --brd: #334155; 
    --btn: #1e293b; 
}

/* Upgraded Grease Mode Variable Modifier */
body.grease-mode {
    --touch-target: 60px;
    font-size: 1.15rem;
}
body.grease-mode .fd, body.grease-mode .fl, body.grease-mode .btn, body.grease-mode .tab-btn {
    padding: 16px !important;
    margin-bottom: 4px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; display: flex; flex-direction: column; height: 100vh; background: var(--bg); color: var(--txt); overflow: hidden; }

/* RESTORED: Your premium header branding structure */
header { 
    background: var(--hd); color: #fff; padding: 12px 20px; 
    display: flex; justify-content: space-between; align-items: center; 
    border-bottom: 1px solid var(--brd); height: 65px; z-index: 100;
}
.h-left { display: flex; align-items: center; gap: 15px; }
.logo-box { display: flex; align-items: center; }
/* Inverts the black logo to white so it contrasts beautifully with the dark header */
.logo-box img {
    height: 64px;
    width: auto;
    object-fit: contain;
    filter: brightness(0) invert(1); /* Forces all dark pixels to pure white */
    opacity: 0.95; /* Softens it slightly to look professional */
}

header h1 { 
    /* Force high-end wide-set geometric proportions */
    font-family: "Arial Black", -apple-system, sans-serif; 
    font-weight: 900; 
    text-transform: uppercase; 
    font-size: 1.15rem; 
    line-height: 1.0;
    
    /* The trick: dynamic scaling stretch properties */
    letter-spacing: 1.5px; 
    transform: scaleX(1.1); 
    transform-origin: left; 
}

header .sub-title { 
    font-size: 0.72rem; 
    color: var(--mt); 
    display: block; 
    margin-top: 5px; 
    letter-spacing: 0.2px;
}

.icon-btn { background: none; border: none; color: white; font-size: 1.4rem; cursor: pointer; display: none; min-width: var(--touch-target); min-height: var(--touch-target); }
.h-right { display: flex; gap: 8px; }
.btn { background: var(--btn); border: 1px solid var(--brd); color: #fff; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 0.85rem; min-height: 34px; }
.btn:hover { background: var(--hv); color: var(--txt); }
.btn.active { background: var(--tac); color: #fff; border-color: var(--tac); }

/* Master App Sizing Container */
.main-container { display: flex; flex: 1; height: calc(100vh - 65px); position: relative; }

/* Upgraded Nav Drawer Workspace */
aside { 
    width: var(--sidebar-width); background: var(--sb); 
    border-right: 1px solid var(--brd); display: flex; flex-direction: column; 
    z-index: 90; transition: transform 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
}

.search-box { padding: 12px; border-bottom: 1px solid var(--brd); position: relative; }
input[type="search"], .tool-search input { width: 100%; padding: 8px 12px; border-radius: 6px; border: 1px solid var(--brd); background: var(--bg); color: var(--txt); min-height: var(--touch-target); }
.search-results { position: absolute; top: 100%; left: 12px; right: 12px; background: var(--sb); border: 1px solid var(--brd); border-radius: 6px; max-height: 250px; overflow-y: auto; z-index: 110; box-shadow: 0 4px 12px rgba(0,0,0,0.1); list-style: none; }

/* Tabbed Layout Interfaces inside sidebar */
.tab-selectors { display: flex; border-bottom: 1px solid var(--brd); background: rgba(0,0,0,0.02); }
.tab-btn { flex: 1; border: none; background: none; padding: 10px; cursor: pointer; font-weight: 600; font-size: 0.8rem; color: var(--mt); border-bottom: 2px solid transparent; min-height: var(--touch-target); }
.tab-btn.active { color: var(--tac); border-bottom-color: var(--tac); background: var(--sb); }
.tab-content { flex: 1; overflow-y: auto; padding: 12px; }

/* RESTORED: Your precise tree item mechanics and hover variables */
#tc ul { list-style: none; }
#tc li { margin-left: 12px; }
.fd, .fl { padding: 6px 10px; cursor: pointer; border-radius: 4px; display: flex; align-items: center; min-height: var(--touch-target); font-size: 0.9rem; }
.fd { font-weight: 600; color: var(--fl); }
.fl { color: var(--tac); }
/* RESTORED: Fixed your missing hover rule variable definition */
.fd:hover, .fl:hover { background: var(--hv); }

/* Tool Cards Render outputs */
.tool-results { font-size: 0.85rem; line-height: 1.4; }
.placeholder-text { color: var(--mt); text-align: center; padding: 20px 10px; }
.dtc-card, .ccf-card { background: var(--bg); border: 1px solid var(--brd); border-radius: 6px; padding: 12px; margin-bottom: 12px; }
.dtc-header { color: var(--tac); font-weight: 700; margin-bottom: 4px; }
.ccf-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.ccf-table th, .ccf-table td { padding: 6px; text-align: left; border-bottom: 1px solid var(--brd); font-size: 0.8rem; }

/* Document Frame Core View Window */
.content-view { flex: 1; height: 100%; background: #525659; position: relative; }

/* 🌟 SAFE RESPONSIVE SAFARI IFRAME INJECTED SCROLLING WRAPPER 🌟 */
.safari-iframe-wrapper {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}
.safari-iframe-wrapper iframe { width: 100%; height: 100%; border: none; display: block; }

.hidden { display: none !important; }

/* ==========================================================================
   📱 MOBILE & TABLET DEVICE VIEWPORT MEDIA BREAKPOINTS
   ========================================================================== */
@media (max-width: 1024px) {
    .icon-btn { display: block; }
    aside {
        position: absolute; top: 0; left: 0; bottom: 0;
        transform: translateX(-100%); box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }
    aside.open { transform: translateX(0); }
    .overlay { position: fixed; top: 65px; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 85; }
}
/* Visual Parts Tab Layout Grid */
.parts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding-top: 12px;
}

.parts-card {
    background: var(--btn);
    border: 1px solid var(--brd);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.parts-card:hover {
    background: var(--hv);
}

/* Forces all vector nodes inside the parts cards to render as bright white */
.parts-icon-wrapper svg {
    color: #ffffff !important;
    fill: currentColor;
    width: 40px;
    height: 40px;
    display: block;
    transition: transform 0.15s ease;
}

/* Keeps the responsive scale behavior working smoothly for grease mode */
body.grease-mode .parts-icon-wrapper svg {
    transform: scale(1.3);
}

.parts-card span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--txt);
    line-height: 1.2;
}

/* Big Button Scaling for oily/gloved hands */
body.grease-mode .parts-card {
    padding: 24px 12px;
}
body.grease-mode .parts-card img {
    height: 55px;
}

/* Custom Embedded Parts Catalog Table Overrides */
.catalog-display-table td {
    color: var(--txt);
}

.catalog-display-table th {
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Adjustments for big greasy fingers working on assemblies */
body.grease-mode .catalog-display-table th,
body.grease-mode .catalog-display-table td {
    padding: 20px 18px !important;
    font-size: 1.1rem !important;
}

body.grease-mode .copy-sku-btn {
    padding: 10px 16px !important;
    font-size: 0.9rem !important;
}