.app-container {
    display: flex;
    min-height: 100vh;
}

/* --- Mobile Header --- */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    padding: 0 var(--spacing-md);
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

/* Small on purpose: the header is 60px tall and the logo is a 6.7:1 wordmark,
   so anything larger dominates the screen on a phone. */
.mobile-logo {
    height: 22px;
    width: auto;
    max-width: 50%;
    object-fit: contain;
}

.mobile-header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.mobile-nav-toggle,
.mobile-search-toggle {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.mobile-nav-toggle:hover,
.mobile-search-toggle:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.mobile-nav-toggle:active,
.mobile-search-toggle:active {
    transform: scale(0.92);
}

.mobile-nav-toggle svg {
    width: 22px;
    height: 22px;
}

.mobile-search-toggle .material-symbols-rounded {
    font-size: 22px;
}

/* --- Sidebar Navigation --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: width 0.35s cubic-bezier(0.32, 0.72, 0, 1),
        transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    font-family: 'Google Sans Flex', 'Google Sans', 'Google Sans Flex', sans-serif;
}

.sidebar > div:not(.sidebar-mobile-header) {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Ported from the Pricing Desk: a soft filled disc that sits inside the
   sidebar's top-right corner, rather than a bordered notch hanging off the
   edge and over the content. Collapsed, it drops into the flow and centres
   itself where the logo header used to be. */
.sidebar-collapse-btn {
    position: absolute;
    top: 20px;
    right: 10px;
    z-index: 1;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition-base), background var(--transition-base),
        transform var(--transition-base);
}

.sidebar-collapse-btn:hover {
    background: var(--bg-active);
    color: var(--primary-text);
    transform: translateX(-1px);
}

.sidebar-collapse-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.sidebar-collapse-btn .material-symbols-rounded {
    font-family: 'Material Symbols Rounded';
    font-weight: 400;
    font-style: normal;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    font-size: 20px;
    line-height: 1;
    font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20;
}

/* --- Sidebar Mobile Header (visible only on mobile) --- */
.sidebar-mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
    flex-shrink: 0;
}

/* The cap is a safety net for very narrow screens; at 60% it was binding at
   normal widths and letterboxing the wordmark below its 22px. */
.sidebar-mobile-header .sidebar-mobile-logo {
    height: 22px;
    width: auto;
    max-width: 75%;
    object-fit: contain;
}

.sidebar-close-btn {
    display: none;
    width: 38px;
    height: 38px;
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    font-size: 0px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-close-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.sidebar-close-btn:hover {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
}

.sidebar-close-btn:active {
    transform: scale(0.9);
}

/* The right padding is the collapse disc's berth: it keeps the centred
   wordmark clear of the button instead of ending 2px short of it. */
.logo-header {
    padding: var(--spacing-lg);
    padding-right: calc(var(--spacing-lg) + 22px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    border-bottom: 1px solid var(--border-light);
    text-align: center;
}

/* The wordmark is 1401x209, so height drives the width: at 32px it ran 215px
   and spilled past the header's own padding in a 250px sidebar. */
.logo-header .logo {
    height: 24px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.logo-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Tool Search --- */
.nav-search {
    flex-shrink: 0;
    padding: var(--spacing-md) var(--spacing-md) 0;
}

.nav-search-field {
    position: relative;
    display: flex;
    align-items: center;
}

.nav-search-icon {
    position: absolute;
    left: 10px;
    font-size: 18px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--transition-fast), left var(--transition-base);
}

/* Matches .input-field — white fill and a medium border, the same furniture
   every other field in the toolbox uses. */
.nav-search-input {
    width: 100%;
    min-width: 0;
    padding: 9px 32px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    -webkit-appearance: none;
    appearance: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.nav-search-input::-webkit-search-cancel-button,
.nav-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.nav-search-input::placeholder {
    color: var(--text-muted);
}

.nav-search-input:hover {
    border-color: var(--text-secondary);
}

.nav-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.nav-search-field:hover .nav-search-icon,
.nav-search-field:focus-within .nav-search-icon {
    color: var(--primary);
}

.nav-search-clear {
    position: absolute;
    right: 5px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-search-clear:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-search-clear .material-symbols-rounded {
    font-size: 18px;
}

.nav-search-empty {
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.tool-grid-empty {
    padding: var(--spacing-lg);
    background: var(--bg-card);
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    color: var(--text-secondary);
    text-align: center;
}

.main-nav li[hidden],
.tool-card[hidden] {
    display: none;
}

.main-nav {
    flex: 1;
    padding: var(--spacing-md) 0;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
}

/* Everything else about this scrollbar - width, pill, colours - is the shared
   treatment in base.css. The tool list only insets its own track so the thumb
   stops short of the header and the footer. */
.main-nav::-webkit-scrollbar-track {
    margin-block: var(--spacing-xs);
}

@media screen and (min-width: 769px) {
    .sidebar.collapsed {
        width: var(--sidebar-collapsed-width);
    }

    .sidebar.collapsed + .main-content {
        margin-left: var(--sidebar-collapsed-width);
    }

    .sidebar.collapsed .logo-header {
        display: none;
    }

    /* Collapsed there is no header to pin to, so the disc leaves the corner
       and stands in the flow where the logo header used to be. */
    .sidebar.collapsed .sidebar-collapse-btn {
        position: static;
        margin: var(--spacing-md) auto var(--spacing-xs);
    }

    .sidebar.collapsed .sidebar-collapse-btn:hover {
        transform: translateX(1px);
    }

    .sidebar.collapsed .nav-search {
        padding: var(--spacing-xs) var(--spacing-xs) 0;
    }

    .sidebar.collapsed .nav-search-input {
        height: 42px;
        padding: 0;
        font-size: 0;
        color: transparent;
        cursor: pointer;
    }

    .sidebar.collapsed .nav-search-icon {
        left: 50%;
        transform: translateX(-50%);
    }

    .sidebar.collapsed .nav-search-clear,
    .sidebar.collapsed .nav-search-empty {
        display: none;
    }

    .sidebar.collapsed .main-nav .nav-link {
        justify-content: center;
        gap: 0;
        padding-left: var(--spacing-xs);
        padding-right: var(--spacing-xs);
        border-left: 0;
        border-right: 3px solid transparent;
        font-size: 0;
    }

    .sidebar.collapsed .main-nav .nav-link.active {
        border-right-color: var(--primary);
    }

    .sidebar.collapsed .main-nav .nav-link::before {
        margin: 0;
    }

    /* No room for the leaves-the-toolbox arrow beside a bare icon. */
    .sidebar.collapsed .main-nav .nav-link.is-external::after {
        display: none;
    }

    /* The signed-in text hides when the 76px sidebar only fits its controls. */
    .sidebar.collapsed .nav-session {
        justify-content: center;
        /* 76px collapsed, less 2 x 4px, leaves 68px for a 66px button row. */
        padding: var(--spacing-sm) 4px;
    }

    .sidebar.collapsed .nav-session-text {
        display: none;
    }

    .sidebar.collapsed .nav-session-actions {
        margin-left: 0;
    }

}

.main-nav ul {
    list-style: none;
}

.main-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    /* The row is sized off the 22px icon, not the label's natural line box:
       22px + 2 x 7px of padding is a 36px row, tight enough that the tool
       list reads as one block. */
    padding: 7px var(--spacing-lg);
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 22px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all var(--transition-fast);
}

.main-nav .nav-link::before,
.main-nav .nav-link.is-external::after,
.tool-card h3::before,
.tool-card.is-external h3::after {
    font-family: 'Material Symbols Rounded';
    font-weight: 400;
    font-style: normal;
    letter-spacing: 0;
    line-height: 1;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.main-nav .nav-link::before {
    content: "apps";
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 20px;
    transition: color var(--transition-fast), font-variation-settings var(--transition-fast);
}

.main-nav .nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* The accent is a fill, never the ink: --primary is 2.45:1 on white and 2.3:1
   on the --bg-active tint this row sits on, so the label and its icon take
   --primary-text (5.37:1) while the rail keeps --primary. */
.main-nav .nav-link:hover::before {
    color: var(--primary-text);
}

.main-nav .nav-link.active {
    background: var(--bg-active);
    color: var(--primary-text);
    border-left-color: var(--primary);
    font-weight: 600;
}

.main-nav .nav-link.active::before {
    color: var(--primary-text);
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.main-nav .nav-link[href$="index.html"]::before {
    content: "dashboard";
}

.main-nav .nav-link[href$="emi-calculator.html"]::before,
.tool-card[href$="emi-calculator.html"] h3::before {
    content: "calculate";
}

.main-nav .nav-link[href$="gst-calculator.html"]::before,
.tool-card[href$="gst-calculator.html"] h3::before {
    content: "percent";
}

.main-nav .nav-link[href$="package-prices.html"]::before,
.tool-card[href$="package-prices.html"] h3::before {
    content: "sell";
}

.main-nav .nav-link[href$="solar-savings.html"]::before,
.tool-card[href$="solar-savings.html"] h3::before {
    content: "savings";
}

.main-nav .nav-link[href$="receipt-generator.html"]::before,
.tool-card[href$="receipt-generator.html"] h3::before {
    content: "receipt_long";
}

.main-nav .nav-link[href$="invoice-generator.html"]::before,
.tool-card[href$="invoice-generator.html"] h3::before {
    content: "description";
}

.main-nav .nav-link[href$="proforma-invoice.html"]::before,
.tool-card[href$="proforma-invoice.html"] h3::before {
    content: "article";
}

.main-nav .nav-link[href$="quotation.html"]::before,
.tool-card[href$="quotation.html"] h3::before {
    content: "draft";
}

.main-nav .nav-link[href$="purchase-order.html"]::before,
.tool-card[href$="purchase-order.html"] h3::before {
    content: "shopping_cart";
}

.main-nav .nav-link[href$="payslip-generator.html"]::before,
.tool-card[href$="payslip-generator.html"] h3::before {
    content: "badge";
}

.main-nav .nav-link[href$="warranty-card.html"]::before,
.tool-card[href$="warranty-card.html"] h3::before {
    content: "verified";
}

.main-nav .nav-link[href$="quote-generator.html"]::before,
.tool-card[href$="quote-generator.html"] h3::before {
    content: "request_quote";
}

.main-nav .nav-link[href$="comparison-sheet.html"]::before,
.tool-card[href$="comparison-sheet.html"] h3::before {
    content: "balance";
}

.main-nav .nav-link[href$="margin-breakdown.html"]::before,
.tool-card[href$="margin-breakdown.html"] h3::before {
    content: "pie_chart";
}

.main-nav .nav-link[href$="resource-library.html"]::before,
.tool-card[href$="resource-library.html"] h3::before {
    content: "library_books";
}

.main-nav .nav-link[href$="request-for-quotation.html"]::before,
.tool-card[href$="request-for-quotation.html"] h3::before {
    content: "format_quote";
}

.main-nav .nav-link[href$="letterheadify.html"]::before,
.tool-card[href$="letterheadify.html"] h3::before {
    content: "picture_as_pdf";
}

/* Matched on host rather than file name: this one leaves the toolbox. */
.main-nav .nav-link[href*="pricing.ray2voltsolar.com"]::before,
.tool-card[href*="pricing.ray2voltsolar.com"] h3::before {
    content: "price_change";
}

/* An item that navigates away from the toolbox says so. */
.main-nav .nav-link.is-external::after,
.tool-card.is-external h3::after {
    content: "open_in_new";
    margin-left: auto;
    flex: 0 0 auto;
    font-size: 15px;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.main-nav .nav-link.is-external:hover::after,
.tool-card.is-external:hover h3::after {
    color: var(--primary-text);
}

/* --- Signed-in information ---
   Account identity, Theme and sign out sit below the scrolling nav. The
   decorative avatar badge has deliberately been removed. */
.nav-session {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    border-top: 1px solid var(--border-light);
    background: var(--bg-sidebar);
}

.nav-session-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.nav-session-label {
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.nav-session-account-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-session-actions {
    margin-left: auto;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 2px;
}

.nav-session-theme,
.nav-session-out {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nav-session-theme .material-symbols-rounded,
.nav-session-out .material-symbols-rounded {
    font-size: 19px;
}

.nav-session-theme:hover,
.nav-session-out:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--primary-text);
}

.nav-session-theme:active,
.nav-session-out:active {
    background: var(--bg-active);
}

.nav-session-theme:focus-visible,
.nav-session-out:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

/* --- Main Content Area --- */
