/* Top bar and action bar styles for the GST return modules.
   Moved here from <style> blocks inside the .razor files on 06-Nov-2026. Almost all of it is phone
   layout behind a media query; desktop is not changed.
   These rules cannot live in a scoped .razor.css: they reach into GstActionBar, and many start at body:has(...).
   They are global, so every selector must start from its module's own class. Never add a bare
   .root-container rule here: it would apply to every page in the app.
   This file is linked last in App.razor so these rules still come after every other stylesheet. */

.spq-topbar-wrap { position: relative; }
.spq-topbar-overlay { position: absolute; inset: 0; z-index: 5; cursor: not-allowed; background: transparent; }
.spq-viewer-only > .d-flex { opacity: .55; pointer-events: none; }

/* ===== GSTR-1 top bar (Gstr1TopBar.razor) ===== */
/* Ramesh (06-Nov-2026): small phones - equal-width tiles were narrower than their label, so "Summary" / "Download" were cut and ran into the next tile. Each tile now takes the width of its own label. */
@media (max-width: 430px) {
    .gstr1-topbar.gstr1-topbar .spq-abar.is-mobile .spq-abar__sbtn { flex: 1 1 auto !important; min-width: min-content !important; width: auto !important; padding-left: 1px !important; padding-right: 1px !important; }
    .gstr1-topbar.gstr1-topbar .spq-abar.is-mobile .spq-abar__sbico { width: auto !important; min-width: 24px; }
    .gstr1-topbar.gstr1-topbar .spq-abar.is-mobile .spq-abar__sblbl { white-space: normal !important; word-break: normal !important; overflow-wrap: normal !important; hyphens: none !important; max-width: none !important; overflow: visible !important; font-size: 10px !important; }
}

/* ===== GSTR-1 / 1A Summary action bar (Gstr1SummaryActions.razor) ===== */
/* Ramesh (04-Nov-2026) — where the X sits. Desktop: far right of the button row's first line.
   Phones: on the same line as the tiles (as on Table 8A / Purchase Register), labels a touch smaller so
   "Download" fits beside it. Only these two summary pages (GSTR-1 / GSTR-1A) carry .g1sum-actbar. */
body:has(.g1sum-actbar) .gstr1-status-action-row > .go-back-close-btn {
    flex: 0 0 auto;
    align-self: flex-start;
    margin-left: auto;
}
@media (max-width: 767.98px) {
    body:has(.g1sum-actbar) .gstr1-status-action-row:has(.spq-abar.is-mobile) {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
    }
    body:has(.g1sum-actbar) .gstr1-status-action-row:has(.spq-abar.is-mobile) > .g1sum-actbar {
        flex: 1 1 0% !important;
        width: auto !important;
        min-width: 0 !important;
    }
    body:has(.g1sum-actbar) .gstr1-status-action-row:has(.spq-abar.is-mobile) > .go-back-close-btn {
        flex: 0 0 30px !important;
        width: 30px;
        min-height: 44px;
        align-self: center !important;
        margin-left: 0;
    }
    body:has(.g1sum-actbar) .g1sum-actbar.is-mobile .spq-abar__sbtn {
        padding-left: 1px !important;
        padding-right: 1px !important;
    }
    body:has(.g1sum-actbar) .g1sum-actbar.is-mobile .spq-abar__sblbl {
        font-size: 9.5px !important;
        line-height: 1.15 !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        max-width: none !important;
    }
}
/* Ramesh (04-Nov-2026): small phones (360px) — labels ran into each other ("TemplateImport…"):
   a little gap between tiles, slightly smaller text, breaks only between words. */
@media (max-width: 400px) {
    body:has(.g1sum-actbar) .g1sum-actbar.is-mobile .spq-abar__strip { gap: 1px !important; }
    body:has(.g1sum-actbar) .g1sum-actbar.is-mobile .spq-abar__sblbl {
        font-size: 8.5px !important;
        word-break: normal !important;
        overflow-wrap: normal !important;
    }
}
/* Ramesh (06-Nov-2026): small phones - equal-width tiles were narrower than their label, so "Summary" / "Download" were cut and ran into the next tile. Each tile now takes the width of its own label. */
@media (max-width: 430px) {
    body:has(.g1sum-actbar) .g1sum-actbar.is-mobile .spq-abar__sbtn { flex: 1 1 auto !important; min-width: min-content !important; width: auto !important; padding-left: 1px !important; padding-right: 1px !important; }
    body:has(.g1sum-actbar) .g1sum-actbar.is-mobile .spq-abar__sbico { width: auto !important; min-width: 24px; }
    body:has(.g1sum-actbar) .g1sum-actbar.is-mobile .spq-abar__sblbl { white-space: normal !important; word-break: normal !important; overflow-wrap: normal !important; hyphens: none !important; max-width: none !important; overflow: visible !important; font-size: 9px !important; }
}

/* ===== GSTR-3B top bar (Gstr3bTopBar.razor) ===== */
/* Ramesh (04-Nov-2026) — phones only (UI only): at 360px the X wrapped to its own line under the tiles, and
   "Download" broke mid-word ("Downloa / d"). Keep the X at the right end of the tile row; break labels between words only. */
@media (max-width: 767.98px) {
    .gstr3b-topbar:has(> .gstr3b-actbar.is-mobile) { flex-wrap: nowrap !important; align-items: center !important; gap: 0 !important; }
    .gstr3b-topbar > .gstr3b-actbar.is-mobile { flex: 1 1 0% !important; min-width: 0 !important; width: auto !important; }
    .gstr3b-topbar:has(> .gstr3b-actbar.is-mobile) > .go-back-close-btn { flex: 0 0 30px !important; width: 30px; min-height: 44px; }
    .gstr3b-topbar .gstr3b-actbar.is-mobile .spq-abar__sbtn { padding-left: 1px !important; padding-right: 1px !important; }
    /* "Download" is the longest word in the row: give its tile a bit more width than the others. */
    .gstr3b-topbar .gstr3b-actbar.is-mobile .spq-abar__sbtn:has(.spq-abar__sblbl):is([aria-label*="Download" i]) { flex-grow: 1.45 !important; }
    .gstr3b-topbar .gstr3b-actbar.is-mobile .spq-abar__sblbl {
        word-break: normal !important;
        overflow-wrap: normal !important;
        hyphens: none !important;
        font-size: 10px !important;
        line-height: 1.15 !important;
    }
}

/* ===== GSTR-2A top bar (Gstr2aTopBar.razor) ===== */
/* Ramesh (31-Oct-2026) — phone fixes (UI only) for the GSTR-2A middle bar, same look as the GSTR-1 and
   E-Invoice pages. Lives in this module's own top bar, so it reaches only the GSTR-2A screens and only while one
   of them is open; title bar, grid and desktop layout untouched. */
@media (max-width: 768px) {
    /* Room under the grid so its last rows end above the round Help / Bug / AI buttons. */
    body:has(.g2a-topbar) .root-container {
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Help / Bug / AI buttons sat over the "More" sheet — hide them while it is open. */
    body:has(.g2a-topbar .spq-abar__sheet) :is(.ai-fab, .spq-bugwidget-fab, .spq-help-fab) {
        visibility: hidden !important;
    }

    /* Was one sideways-scrolling line with the action tiles pushed off screen. Now ONE row:
       the sections of this family as a compact segmented pill with short codes (B2B | B2BA,
       TDS | TDSA | TCS …), a thin divider, then equal action tiles, "Summary" first as on GSTR-1. */
    .g2a-topbar:has(.spq-abar.is-mobile) {
        flex-wrap: nowrap !important;
        gap: 0 !important;
        align-items: stretch !important;
        border-bottom: 1px solid var(--bd, #e7ecf3);
    }
    .g2a-topbar:has(.spq-abar.is-mobile) .slbs { flex: 1 1 0% !important; min-width: 0 !important; width: auto !important; }
    .g2a-topbar:has(.spq-abar.is-mobile) .slbs__nav,
    .g2a-topbar:has(.spq-abar.is-mobile) .slbs::before,
    .g2a-topbar:has(.spq-abar.is-mobile) .slbs::after { display: none !important; }
    .g2a-topbar:has(.spq-abar.is-mobile) .slbs__track {
        overflow: visible !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: 0 !important;
    }

    /* The desktop Summary link is replaced by the "Summary" tile; the dividers have no job here. */
    .g2a-topbar:has(.spq-abar.is-mobile) .slbs__track > :is(a.btn, .vr) { display: none !important; }

    /* Section links → compact segmented pill at the left: active one filled, others outlined,
       short codes instead of the full names, divider line before the action tiles. */
    .g2a-topbar:has(.spq-abar.is-mobile) .slbs__track > .btn-group {
        order: -1;
        flex: 0 0 auto !important;
        display: flex !important;
        align-self: center;
        margin: 0 4px 0 0 !important;
        padding-right: 4px;
        border-right: 1px solid var(--bd, #e7ecf3);
    }
    .g2a-topbar:has(.spq-abar.is-mobile) .slbs__track > .btn-group > .btn {
        min-height: 44px !important;
        padding: 2px 7px !important;
        font-size: 11px !important;
        line-height: 1.1 !important;
        letter-spacing: 0 !important;
        white-space: nowrap !important;
    }
    .g2a-topbar:has(.spq-abar.is-mobile) .slbs__track > .btn-group > .btn > i { display: none !important; }
    .g2a-topbar:has(.spq-abar.is-mobile) .g2a-lbl-full { display: none !important; }
    .g2a-topbar:has(.spq-abar.is-mobile) .g2a-lbl-short { display: inline !important; }

    .g2a-topbar .slbs__track > .spq-abar.is-mobile { flex: 1 1 0% !important; min-width: 0; width: auto; }

    /* Verify GSTINs keeps its choice popup (and confirm / login dialogs) inside the hidden desktop
       row, so keep that row collapsed and invisible instead of removed — the popup still shows. */
    .g2a-topbar .spq-abar.is-mobile .spq-abar__row {
        display: flex !important;
        height: 0 !important;
        min-height: 0 !important;
        width: 0 !important;
        min-width: 0 !important;
        flex: 0 0 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
    }
    .g2a-topbar .spq-abar.is-mobile .spq-abar__row :is(.modal, .modal-backdrop) { visibility: visible !important; }
    .g2a-topbar .spq-abar.is-mobile .spq-abar__sbtn[aria-label="Cancel"] { display: none !important; }

    .g2a-topbar .spq-abar.is-mobile .spq-abar__strip {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        width: 100%;
        border-bottom: 0 !important;
        padding-left: 2px !important;
        padding-right: 2px !important;
    }
    .g2a-topbar .spq-abar.is-mobile .spq-abar__sbtn {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        width: auto !important;
        padding-left: 1px !important;
        padding-right: 1px !important;
    }
    /* Two-line labels instead of "Downloa". */
    .g2a-topbar .spq-abar.is-mobile .spq-abar__sblbl {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        max-width: none !important;
        line-height: 1.15 !important;
        text-align: center;
        font-size: 10.5px !important;
    }

    /* Grid "Column visibility & settings" gear not needed on phones (Ramesh asked, 31-Oct-2026).
       Hidden from here, not in SmartGrid, so it only goes away on the GSTR-2A screens. */
    body:has(.g2a-topbar) .smartgrid-header .slbs__track > .flex-shrink-0:has(> .btn-group > button[title^="Column visibility"]) {
        display: none !important;
    }

    /* X: on a section page it duplicates the "Summary" tile, so it goes (as on GSTR-1). On the
       Summary page there is no such tile, so the X stays, with a thumb-sized target. */
    .g2a-topbar:has(.spq-ab.g2a-phone-only):has(.spq-abar.is-mobile) > .go-back-close-btn { display: none !important; }
    .g2a-topbar:has(.spq-abar.is-mobile) > .go-back-close-btn { flex: 0 0 36px; width: 36px; min-height: 44px; align-self: center; }
}

/* Desktop: the phone-only tiles never show in the desktop row — it keeps its own links. */
.g2a-topbar .spq-ab.g2a-phone-only { display: none !important; }
/* Desktop: section links keep their full names; the short codes are for phones only. */
.g2a-topbar .g2a-lbl-short { display: none; }
/* Ramesh (06-Nov-2026): small phones - equal-width tiles were narrower than their label, so "Summary" / "Download" were cut and ran into the next tile. Each tile now takes the width of its own label. */
@media (max-width: 430px) {
    .g2a-topbar .spq-abar.is-mobile .spq-abar__sbtn { flex: 1 1 auto !important; min-width: min-content !important; width: auto !important; padding-left: 1px !important; padding-right: 1px !important; }
    .g2a-topbar .spq-abar.is-mobile .spq-abar__sbico { width: auto !important; min-width: 24px; }
    .g2a-topbar .spq-abar.is-mobile .spq-abar__sblbl { white-space: normal !important; word-break: normal !important; overflow-wrap: normal !important; hyphens: none !important; max-width: none !important; overflow: visible !important; font-size: 10px !important; }
}

/* ===== GSTR-2B top bar (Gstr2bTopBar.razor) ===== */
/* Ramesh (31-Oct-2026) — phone fixes (UI only) for the GSTR-2B middle bar, same look as GSTR-2A: ONE row —
   the summary tabs as a compact segmented pill at the left, a thin divider, then the action tiles, X at the right.
   Lives in this module's own top bar, so it reaches every GSTR-2B screen and only while one is open; title bar,
   grid and desktop layout untouched. */
@media (max-width: 768px) {
    /* Room under the grid so its last rows end above the round Help / Bug / AI buttons. */
    body:has(.g2b-topbar) .root-container {
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    }
    /* Help / Bug / AI buttons sat over the "More" / Export sheet — hide them while it is open. */
    body:has(.g2b-topbar .spq-abar__sheet) :is(.ai-fab, .spq-bugwidget-fab, .spq-help-fab) {
        visibility: hidden !important;
    }

    /* Was the 4 tabs filling the line with the Download / Export / Delete tiles pushed off screen. */
    .g2b-topbar:has(.spq-abar.is-mobile) {
        flex-wrap: nowrap !important;
        gap: 0 !important;
        align-items: stretch !important;
        border-bottom: 1px solid var(--bd, #e7ecf3);
    }
    .g2b-topbar:has(.spq-abar.is-mobile) .slbs { flex: 1 1 0% !important; min-width: 0 !important; width: auto !important; }
    .g2b-topbar:has(.spq-abar.is-mobile) .slbs__nav,
    .g2b-topbar:has(.spq-abar.is-mobile) .slbs::before,
    .g2b-topbar:has(.spq-abar.is-mobile) .slbs::after { display: none !important; }
    .g2b-topbar:has(.spq-abar.is-mobile) .slbs__track {
        overflow: visible !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: 0 !important;
    }
    .g2b-topbar:has(.spq-abar.is-mobile) .slbs__track > .vr { display: none !important; }

    /* Tabs → compact segmented pill: active one filled, others outlined, two-line labels ("ITC / Avail"). */
    .g2b-topbar:has(.spq-abar.is-mobile) .slbs__track > .btn-group {
        flex: 0 0 auto !important;
        display: flex !important;
        align-self: center;
        margin: 0 4px 0 0 !important;
        padding-right: 4px;
        border-right: 1px solid var(--bd, #e7ecf3);
    }
    .g2b-topbar:has(.spq-abar.is-mobile) .slbs__track > .btn-group > .btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 52px;
        min-height: 44px !important;
        padding: 2px 4px !important;
        font-size: 10.5px !important;
        line-height: 1.1 !important;
        letter-spacing: 0 !important;
        white-space: normal !important;
        text-align: center;
    }

    .g2b-topbar .slbs__track > .spq-abar.is-mobile { flex: 1 1 0% !important; min-width: 0; width: auto; }

    /* Keep the desktop row collapsed, not removed, so a popup opened from it can still show. */
    .g2b-topbar .spq-abar.is-mobile .spq-abar__row {
        display: flex !important;
        height: 0 !important;
        min-height: 0 !important;
        width: 0 !important;
        min-width: 0 !important;
        flex: 0 0 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
    }
    .g2b-topbar .spq-abar.is-mobile .spq-abar__row :is(.modal, .modal-backdrop) { visibility: visible !important; }
    .g2b-topbar .spq-abar.is-mobile .spq-abar__sbtn[aria-label="Cancel"] { display: none !important; }

    .g2b-topbar .spq-abar.is-mobile .spq-abar__strip {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        width: 100%;
        border-bottom: 0 !important;
        padding-left: 2px !important;
        padding-right: 2px !important;
    }
    .g2b-topbar .spq-abar.is-mobile .spq-abar__sbtn {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        width: auto !important;
        padding-left: 1px !important;
        padding-right: 1px !important;
    }
    .g2b-topbar .spq-abar.is-mobile .spq-abar__sblbl {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        max-width: none !important;
        line-height: 1.15 !important;
        text-align: center;
        font-size: 10.5px !important;
    }

    /* Grid "Column visibility & settings" gear not needed on phones (Ramesh asked, 31-Oct-2026).
       Hidden from here, not in SmartGrid, so it only goes away on the GSTR-2B screens. */
    body:has(.g2b-topbar) .smartgrid-header .slbs__track > .flex-shrink-0:has(> .btn-group > button[title^="Column visibility"]) {
        display: none !important;
    }

    /* X kept (Summary pages → Return Dashboard, section pages → ITC Available summary), thumb-sized. */
    .g2b-topbar:has(.spq-abar.is-mobile) > .go-back-close-btn { flex: 0 0 32px; width: 32px; min-height: 44px; align-self: center; }
}
/* Ramesh (06-Nov-2026): small phones - equal-width tiles were narrower than their label, so "Summary" / "Download" were cut and ran into the next tile. Each tile now takes the width of its own label. */
@media (max-width: 430px) {
    .g2b-topbar .spq-abar.is-mobile .spq-abar__sbtn { flex: 1 1 auto !important; min-width: min-content !important; width: auto !important; padding-left: 1px !important; padding-right: 1px !important; }
    .g2b-topbar .spq-abar.is-mobile .spq-abar__sbico { width: auto !important; min-width: 24px; }
    .g2b-topbar .spq-abar.is-mobile .spq-abar__sblbl { white-space: normal !important; word-break: normal !important; overflow-wrap: normal !important; hyphens: none !important; max-width: none !important; overflow: visible !important; font-size: 10px !important; }
    /* The four section tabs took 208px of the row and left the Download / Export / Delete tiles too little. */
    .g2b-topbar:has(.spq-abar.is-mobile) .slbs__track > .btn-group > .btn { width: 44px !important; padding: 2px 1px !important; font-size: 9.5px !important; }
}

/* ===== GSTR-4 top bar (Gstr4TopBar.razor) ===== */
/* Ramesh (02-Nov-2026) — phone fixes (UI only) for the GSTR-4 middle bar, same look as GSTR-1 / GSTR-7: one
   full-width row of equal tiles (overflow in the bar's own "More" sheet), labels on two lines, the section screens'
   "Summary" button kept small at the right. Lives in this module's own top bar; title bar, grid and desktop untouched. */
@media (max-width: 768px) {
    /* Room under the grid so its last rows end above the round Help / Bug / AI buttons. */
    body:has(.gstr4-topbar) .root-container {
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    }
    /* Help / Bug / AI buttons sat over the "More" sheet — hide them while it is open. */
    body:has(.gstr4-topbar .spq-abar__sheet) :is(.ai-fab, .spq-bugwidget-fab, .spq-help-fab) {
        visibility: hidden !important;
    }

    /* Was: the strip got only part of the width and labels were cut ("Downloa", "Compar"). */
    .gstr4-topbar:has(.spq-abar.is-mobile) {
        flex-wrap: nowrap !important;
        gap: 0 !important;
        align-items: stretch !important;
        border-bottom: 1px solid var(--bd, #e7ecf3);
        /* CMP-08 / Inward-Outward / TDS-TCS / Prev-Year put the bar in a flex column where it shrank to
           ~316px and "Download" was clipped at the left edge — always take the full width. */
        width: 100% !important;
        align-self: stretch !important;
        min-width: 0;
    }
    .gstr4-topbar:has(.spq-abar.is-mobile) .slbs { flex: 1 1 0% !important; min-width: 0 !important; width: auto !important; }
    .gstr4-topbar:has(.spq-abar.is-mobile) .slbs__nav,
    .gstr4-topbar:has(.spq-abar.is-mobile) .slbs::before,
    .gstr4-topbar:has(.spq-abar.is-mobile) .slbs::after { display: none !important; }
    .gstr4-topbar:has(.spq-abar.is-mobile) .slbs__track {
        overflow: visible !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: 0 !important;
    }
    .gstr4-topbar .slbs__track > .spq-abar.is-mobile { flex: 1 1 0% !important; min-width: 0; width: auto; }

    /* Keep the desktop row collapsed, not removed, so a popup opened from it can still show. */
    .gstr4-topbar .spq-abar.is-mobile .spq-abar__row {
        display: flex !important;
        height: 0 !important;
        min-height: 0 !important;
        width: 0 !important;
        min-width: 0 !important;
        flex: 0 0 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
    }
    .gstr4-topbar .spq-abar.is-mobile .spq-abar__row :is(.modal, .modal-backdrop) { visibility: visible !important; }
    .gstr4-topbar .spq-abar.is-mobile .spq-abar__sbtn[aria-label="Cancel"] { display: none !important; }

    .gstr4-topbar .spq-abar.is-mobile .spq-abar__strip {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        width: 100%;
        border-bottom: 0 !important;
        padding-left: 2px !important;
        padding-right: 2px !important;
    }
    .gstr4-topbar .spq-abar.is-mobile .spq-abar__sbtn {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        width: auto !important;
        padding-left: 1px !important;
        padding-right: 1px !important;
    }
    /* Two-line labels instead of cut ones. */
    .gstr4-topbar .spq-abar.is-mobile .spq-abar__sblbl {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        max-width: none !important;
        line-height: 1.15 !important;
        text-align: center;
        font-size: 10.5px !important;
    }

    /* Right-hand box: empty on the Summary; on section screens holds "← Summary" — kept small. */
    .gstr4-topbar:has(.spq-abar.is-mobile) > .ms-auto { flex: 0 0 auto; margin-left: 0 !important; align-items: center; }
    .gstr4-topbar:has(.spq-abar.is-mobile) > .ms-auto:empty { display: none !important; }
    .gstr4-topbar:has(.spq-abar.is-mobile) > .ms-auto > .btn {
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        min-height: 56px;
        padding: 4px 4px !important;
        font-size: 10.5px !important;
        line-height: 1.1;
        /* drawn as a tile like the others, not as a boxed desktop button */
        border: 0 !important;
        border-left: 1px solid var(--bd, #e7ecf3) !important;
        border-radius: 0 !important;
        background: transparent !important;
        color: var(--tc-text, #344054) !important;
    }
    .gstr4-topbar:has(.spq-abar.is-mobile) > .ms-auto > .btn > i { margin: 0 !important; font-size: 18px; }
    /* Ramesh (04-Nov-2026): the X at the right end of the tile row. */
    .gstr4-topbar:has(.spq-abar.is-mobile) > .go-back-close-btn { flex: 0 0 30px !important; width: 30px; min-height: 44px; align-self: center !important; }
    /* Ramesh (05-Nov-2026): section screens showed "← Summary" AND the X, both going to the GSTR-4 Summary,
       and the 7 tile labels ran into each other ("ownload", "CompareP…"). On phones the X alone does it. */
    .gstr4-topbar:has(.spq-abar.is-mobile):has(> .go-back-close-btn) > .ms-auto > .btn[title="Go back to GSTR-4 Summary"] { display: none !important; }
    .gstr4-topbar .spq-abar.is-mobile .spq-abar__sblbl { word-break: normal !important; overflow-wrap: normal !important; hyphens: none !important; }

    /* Grid "Column visibility & settings" gear not needed on phones (same as the other return modules).
       Hidden from here, not in SmartGrid, so it only goes away on the GSTR-4 screens. */
    body:has(.gstr4-topbar) .smartgrid-header .slbs__track > .flex-shrink-0:has(> .btn-group > button[title^="Column visibility"]) {
        display: none !important;
    }
}
/* Ramesh (05-Nov-2026): 7 tiles on a 360px phone — a touch smaller so "Download" / "Populate" fit whole. */
@media (max-width: 400px) {
    .gstr4-topbar:has(> .ms-auto > .btn[title="Go back to GSTR-4 Summary"]) .spq-abar.is-mobile .spq-abar__sblbl { font-size: 9px !important; letter-spacing: -0.2px; }
}

/* Ramesh (02-Nov-2026): the GSTR-4 grids showed the same pager twice — in the grid header and below
   the rows. Keep only the one below the rows (phones AND desktop, as asked). Only when that bottom
   pager is actually there, so a grid is never left without one. Hidden from here, not in SmartGrid. */
body:has(.gstr4-topbar) .smartgrid-root:has(> .smartgrid-mini-pager) .smartgrid-header > .spq-pager-bar {
    display: none !important;
}

/* ===== GSTR-6 top bar (Gstr6TopBar.razor) ===== */
/* Ramesh (02-Nov-2026) — phone fixes (UI only) for the GSTR-6 middle bar: TWO rows — Summary + the six
   section links as one full-width segmented row, then the action tiles (Status · Download · Import) full width.
   Lives in this module's own top bar, so it reaches only the GSTR-6 screens; title bar, grid and desktop untouched. */
@media (max-width: 768px) {
    /* Room under the content so it ends above the round Help / Bug / AI buttons. */
    body:has(.gstr6-topbar) .root-container {
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    }
    /* Help / Bug / AI buttons sat over a "More" / Download sheet — hide them while it is open. */
    body:has(.gstr6-topbar .spq-abar__sheet) :is(.ai-fab, .spq-bugwidget-fab, .spq-help-fab) {
        visibility: hidden !important;
    }

    /* Was: the seven links ran off the right edge (ITC / ITCA cut) and the tiles were squeezed
       to a third of the width ("Downloa"). */
    .gstr6-topbar:has(.spq-abar.is-mobile) {
        flex-wrap: wrap !important;
        gap: 6px !important;
        align-items: stretch !important;
        border-bottom: 1px solid var(--bd, #e7ecf3);
    }

    /* Row 1 — segmented tabs: equal widths, joined outline, active section filled. */
    .gstr6-topbar:has(.spq-abar.is-mobile) > .gstr6-tabs {
        flex: 1 0 100% !important;
        gap: 0 !important;
        border-radius: 8px;
        overflow: hidden;
    }
    .gstr6-topbar:has(.spq-abar.is-mobile) > .gstr6-tabs > .btn {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        min-height: 44px !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        padding: 2px 2px !important;
        font-size: 11px !important;
        line-height: 1.1 !important;
        letter-spacing: 0 !important;
        white-space: normal !important;
        text-align: center;
        border-radius: 0 !important;
    }
    .gstr6-topbar:has(.spq-abar.is-mobile) > .gstr6-tabs > .btn + .btn { margin-left: -1px; }
    .gstr6-topbar:has(.spq-abar.is-mobile) > .gstr6-tabs > .btn:first-child { border-radius: 8px 0 0 8px !important; }
    .gstr6-topbar:has(.spq-abar.is-mobile) > .gstr6-tabs > .btn:last-child { border-radius: 0 8px 8px 0 !important; }
    /* "← Summary": arrow above the word, so it fits its segment. */
    .gstr6-topbar:has(.spq-abar.is-mobile) > .gstr6-tabs > .btn:first-child { flex-direction: column; gap: 1px; flex-grow: 1.25 !important; }
    .gstr6-topbar:has(.spq-abar.is-mobile) > .gstr6-tabs > .btn > i { margin: 0 !important; font-size: 10px; }

    /* Grid "Column visibility & settings" gear not needed on phones (same as GSTR-2A / 2B / TDS & TCS).
       Hidden from here, not in SmartGrid, so it only goes away on the GSTR-6 screens. */
    body:has(.gstr6-topbar) .smartgrid-header .slbs__track > .flex-shrink-0:has(> .btn-group > button[title^="Column visibility"]) {
        display: none !important;
    }

    /* Row 2 — action tiles, full width. */
    .gstr6-topbar > .spq-abar.is-mobile { flex: 1 0 100% !important; min-width: 0; width: 100%; }
    /* Ramesh (04-Nov-2026): row 2 shares its width with the X at the right end. */
    .gstr6-topbar:has(> .go-back-close-btn) > .spq-abar.is-mobile { flex: 1 1 0% !important; width: auto !important; }
    .gstr6-topbar:has(.spq-abar.is-mobile) > .go-back-close-btn { flex: 0 0 30px !important; width: 30px; min-height: 44px; align-self: center !important; }
    /* The empty login-gate holder (0px high) took a line of its own and pushed the X under the tiles —
       move it to the end; its dialog is fixed-position, so it still opens the same. */
    .gstr6-topbar:has(.spq-abar.is-mobile) > .spq-provider-login-gate-container { order: 10; }

    /* Keep the desktop row collapsed, not removed, so a popup opened from it can still show. */
    .gstr6-topbar .spq-abar.is-mobile .spq-abar__row {
        display: flex !important;
        height: 0 !important;
        min-height: 0 !important;
        width: 0 !important;
        min-width: 0 !important;
        flex: 0 0 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
    }
    .gstr6-topbar .spq-abar.is-mobile .spq-abar__row :is(.modal, .modal-backdrop) { visibility: visible !important; }
    .gstr6-topbar .spq-abar.is-mobile .spq-abar__sbtn[aria-label="Cancel"] { display: none !important; }

    .gstr6-topbar .spq-abar.is-mobile .spq-abar__strip {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        width: 100%;
        border-bottom: 0 !important;
        padding-left: 2px !important;
        padding-right: 2px !important;
    }
    .gstr6-topbar .spq-abar.is-mobile .spq-abar__sbtn {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        width: auto !important;
        padding-left: 1px !important;
        padding-right: 1px !important;
    }
    .gstr6-topbar .spq-abar.is-mobile .spq-abar__sblbl {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        max-width: none !important;
        line-height: 1.15 !important;
        text-align: center;
        font-size: 10.5px !important;
    }
}

/* ===== GSTR-6 Summary page (Gstr6Summary.razor) ===== */
/* ── Page layout ── */

.gstr6-summary-page.container-fluid {
    padding-left: .75rem;
    padding-right: .75rem;
}

/* ── Action tiles: the shared GstActionButton (Docs/GstActionButtons.md) — never restyle .spq-ab here ── */

.gstr6-action-panel {
    padding: .5rem 0 .4rem;
}

/* ── Summary grid card (same shell as GSTR-1 Summary gstr1-summary-grid-card) ── */

.gstr6-summary-grid-card {
    border-radius: 10px;
    overflow: hidden;
}

.gstr6-summary-grid-card .Gstr6SummaryGrid {
    --sheet-bg-color: var(--bs-body-bg, #ffffff);
    --sheet-border-style: 1px solid var(--bs-border-color, #eaecf0);
    --col-header-bg-color: var(--bs-tertiary-bg, #f8fafc);
    --row-header-bg-color: var(--bs-tertiary-bg, #f8fafc);
    --col-header-foreground-color: var(--bs-secondary-color, #475467);
    --row-header-foreground-color: var(--bs-secondary-color, #475467);
    --sheet-foreground-color: var(--bs-body-color, #1d2939);
    --sheet-font-size: 0.8125rem;
    --head-selection-bg-color: color-mix(in srgb, var(--theme-default, #7366ff) 10%, var(--bs-body-bg, #fff));
    --header-selected-bg-color: var(--theme-default, #4f46e5);
    --selection-bg-color: color-mix(in srgb, var(--theme-default, #7366ff) 8%, transparent);
    --selection-border-color: var(--theme-default, #4f46e5);

    border: 1px solid var(--bs-border-color, #eaecf0);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bs-body-bg, #fff);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

.gstr6-summary-grid-card .Gstr6SummaryGrid .smartgrid-toolbar {
    background: var(--bs-tertiary-bg, #f8fafc);
    border-bottom: 1px solid var(--bs-border-color, #eaecf0);
    padding: 4px 8px;
}

.gstr6-summary-grid-card .Gstr6SummaryGrid .sheet-col-head-container {
    font-weight: clamp(1, calc(600 + var(--spq-fw-delta, 0)), 1000);
    letter-spacing: .02em;
}

/* ── section_name hyperlink: no underline at rest, underline on hover ──
   Same convention as GSTR-1 Summary and GSTR-3B Summary. */
.gstr6-summary-grid-card .Gstr6SummaryGrid .grid-link,
.gstr6-summary-grid-card .Gstr6SummaryGrid .grid-link.btn {
    border: 0;
    background: transparent;
    padding: 0;
    margin: 0;
    box-shadow: none;
    font: inherit;
    line-height: inherit;
    text-align: inherit;
    white-space: normal;
    text-decoration: none !important;
    cursor: pointer;
    transition: color .15s ease;
}

.gstr6-summary-grid-card .Gstr6SummaryGrid .grid-link:hover,
.gstr6-summary-grid-card .Gstr6SummaryGrid .grid-link.btn:hover,
.gstr6-summary-grid-card .Gstr6SummaryGrid .grid-link:focus-visible {
    background: transparent;
    text-decoration: underline !important;
    text-underline-offset: 2px;
    cursor: pointer;
}

.gstr6-summary-grid-card .Gstr6SummaryGrid .grid-link:focus-visible {
    outline: 2px solid var(--theme-default, var(--bs-primary));
    outline-offset: 1px;
    border-radius: 2px;
}

/* ── Mobile responsive (≤ 768 px) — native-app feel ── */
@media (max-width: 767.98px) {
    .gstr6-summary-page.container-fluid {
        padding-left: 0;
        padding-right: 0;
    }

    .gstr6-action-panel {
        padding: .5rem .5rem .4rem;
    }

    /* Grid card: edge-to-edge with horizontal scroll */
    .gstr6-summary-grid-card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 0;
        margin-left: 0;
        margin-right: 0;
    }

    .gstr6-summary-grid-card .Gstr6SummaryGrid {
        min-width: 480px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    /* Safe area for notched phones */
    .gstr6-summary-page {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* #region Ramesh (02-Nov-2026) — phone (UI only): JSON / Upload took a whole band of their own under the
   Download / Import / Status tiles. Now the middle bar is two lines: the section tabs, then ONE row of tiles
   Download · Import · Status · JSON · Upload. The top bar is laid out flat into this page (display: contents)
   so its tile strip and this panel sit side by side; desktop untouched. */
@media (max-width: 768px) {
    .gstr6-summary-page:has(.spq-abar.is-mobile) {
        display: flex;
        flex-wrap: wrap;
        align-items: stretch;
    }
    /* Everything else (grid, login-gate holders, …) keeps its own full-width line, after the bar. */
    .gstr6-summary-page:has(.spq-abar.is-mobile) > *,
    .gstr6-summary-page:has(.spq-abar.is-mobile) > .gstr6-topbar > :not(.gstr6-tabs):not(.spq-abar) { flex: 1 0 100%; min-width: 0; order: 3; }
    .gstr6-summary-page:has(.spq-abar.is-mobile) > .gstr6-topbar { display: contents !important; }
    .gstr6-summary-page:has(.spq-abar.is-mobile) > .gstr6-topbar > .gstr6-tabs { order: 1; flex: 1 0 100% !important; margin: 4px 0 6px; }
    /* Tiles row: the top bar's three tiles (3 parts) + JSON / Upload (2 parts) on one line. */
    .gstr6-summary-page:has(.spq-abar.is-mobile) > .gstr6-topbar > .spq-abar.is-mobile {
        order: 2;
        flex: 3 1 230px !important;
        width: auto !important;
        min-width: 0;
    }
    .gstr6-summary-page:has(.spq-abar.is-mobile) > .gstr6-action-panel {
        order: 2;
        flex: 2 1 150px !important;
        min-width: 0;
        padding: 0 !important;
    }
    .gstr6-summary-page .gstr6-action-panel .spq-abar.is-mobile,
    .gstr6-summary-page .gstr6-action-panel .spq-abar.is-mobile .spq-abar__strip {
        width: 100%;
        border-bottom: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    .gstr6-summary-page .gstr6-action-panel .spq-abar.is-mobile .spq-abar__sbtn {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        width: auto !important;
        padding-left: 1px !important;
        padding-right: 1px !important;
    }
    .gstr6-summary-page .gstr6-action-panel .spq-abar.is-mobile .spq-abar__sblbl {
        white-space: normal !important;
        font-size: 10.5px !important;
        line-height: 1.15 !important;
        text-align: center;
    }
    /* One line under the whole tile row, then the grid. */
    .gstr6-summary-page:has(.spq-abar.is-mobile) > .gstr6-summary-grid-card {
        border-top: 1px solid var(--bd, #e7ecf3);
        margin-top: 4px;
        padding-top: 6px;
    }

    /* Ramesh (04-Nov-2026): the new X closes the tile row (it was on a line of its own, under JSON / Upload).
       Tabs 1 · tiles 2 · X 3 · everything else 4. Smaller bases so the five tiles + X fit one line at 360px. */
    .gstr6-summary-page:has(.spq-abar.is-mobile) > *,
    .gstr6-summary-page:has(.spq-abar.is-mobile) > .gstr6-topbar > :not(.gstr6-tabs):not(.spq-abar) { order: 4; }
    .gstr6-summary-page:has(.spq-abar.is-mobile) > .gstr6-topbar > .gstr6-tabs { order: 1; }
    .gstr6-summary-page:has(.spq-abar.is-mobile) > .gstr6-topbar > .spq-abar.is-mobile { order: 2; flex: 3 1 150px !important; }
    .gstr6-summary-page:has(.spq-abar.is-mobile) > .gstr6-action-panel { order: 2; flex: 2 1 100px !important; }
    .gstr6-summary-page:has(.spq-abar.is-mobile) > .gstr6-topbar > .go-back-close-btn {
        order: 3 !important; /* the ":not(tabs):not(bar)" rule above is more specific */
        flex: 0 0 30px !important;
        width: 30px;
        min-height: 44px;
        align-self: center !important;
    }
    .gstr6-summary-page:has(.spq-abar.is-mobile) :is(.gstr6-topbar, .gstr6-action-panel) .spq-abar.is-mobile .spq-abar__sblbl { font-size: 10px !important; }
}
/* #endregion */

/* ===== GSTR-7 top bar (Gstr7TopBar.razor) ===== */
/* Ramesh (02-Nov-2026) — phone fixes (UI only) for the GSTR-7 middle bar, same look as the GSTR-1 pages:
   one full-width row of equal tiles (overflow in the bar's own "More" sheet), labels on two lines, X kept.
   Lives in this module's own top bar, so it reaches only the GSTR-7 screens; title bar, grid and desktop untouched. */
@media (max-width: 768px) {
    /* Room under the content so it ends above the round Help / Bug / AI buttons. */
    body:has(.gstr7-topbar) .root-container {
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    }
    /* Help / Bug / AI buttons sat over the "More" sheet — hide them while it is open. */
    body:has(.gstr7-topbar .spq-abar__sheet) :is(.ai-fab, .spq-bugwidget-fab, .spq-help-fab) {
        visibility: hidden !important;
    }

    /* Was: the strip got ~80% of the width, a ">" arrow sat on the tiles and labels were cut
       ("TDS Ta", "Uploa"). Now one full-width row, X at the right. */
    .gstr7-topbar:has(.spq-abar.is-mobile) {
        flex-wrap: nowrap !important;
        gap: 0 !important;
        align-items: stretch !important;
        border-bottom: 1px solid var(--bd, #e7ecf3);
    }
    .gstr7-topbar:has(.spq-abar.is-mobile) .slbs { flex: 1 1 0% !important; min-width: 0 !important; width: auto !important; }
    .gstr7-topbar:has(.spq-abar.is-mobile) .slbs__nav,
    .gstr7-topbar:has(.spq-abar.is-mobile) .slbs::before,
    .gstr7-topbar:has(.spq-abar.is-mobile) .slbs::after { display: none !important; }
    .gstr7-topbar:has(.spq-abar.is-mobile) .slbs__track {
        overflow: visible !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: 0 !important;
    }
    .gstr7-topbar:has(.spq-abar.is-mobile) .slbs__track > .vr { display: none !important; }
    .gstr7-topbar .slbs__track > .spq-abar.is-mobile { flex: 1 1 0% !important; min-width: 0; width: auto; }

    /* Keep the desktop row collapsed, not removed, so a popup opened from it can still show. */
    .gstr7-topbar .spq-abar.is-mobile .spq-abar__row {
        display: flex !important;
        height: 0 !important;
        min-height: 0 !important;
        width: 0 !important;
        min-width: 0 !important;
        flex: 0 0 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
    }
    .gstr7-topbar .spq-abar.is-mobile .spq-abar__row :is(.modal, .modal-backdrop) { visibility: visible !important; }
    .gstr7-topbar .spq-abar.is-mobile .spq-abar__sbtn[aria-label="Cancel"] { display: none !important; }

    .gstr7-topbar .spq-abar.is-mobile .spq-abar__strip {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        width: 100%;
        border-bottom: 0 !important;
        padding-left: 2px !important;
        padding-right: 2px !important;
    }
    .gstr7-topbar .spq-abar.is-mobile .spq-abar__sbtn {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        width: auto !important;
        padding-left: 1px !important;
        padding-right: 1px !important;
    }
    /* Two-line labels instead of cut ones. */
    .gstr7-topbar .spq-abar.is-mobile .spq-abar__sblbl {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        max-width: none !important;
        line-height: 1.15 !important;
        text-align: center;
        font-size: 10.5px !important;
    }

    /* X kept (Summary → Return Dashboard, other screens → GSTR-7 Summary), thumb-sized. */
    .gstr7-topbar:has(.spq-abar.is-mobile) > .go-back-close-btn { flex: 0 0 32px; width: 32px; min-height: 44px; align-self: center; }
}
/* Ramesh (06-Nov-2026): small phones - equal-width tiles were narrower than their label, so "Summary" / "Download" were cut and ran into the next tile. Each tile now takes the width of its own label. */
@media (max-width: 430px) {
    .gstr7-topbar .spq-abar.is-mobile .spq-abar__sbtn { flex: 1 1 auto !important; min-width: min-content !important; width: auto !important; padding-left: 1px !important; padding-right: 1px !important; }
    .gstr7-topbar .spq-abar.is-mobile .spq-abar__sbico { width: auto !important; min-width: 24px; }
    .gstr7-topbar .spq-abar.is-mobile .spq-abar__sblbl { white-space: normal !important; word-break: normal !important; overflow-wrap: normal !important; hyphens: none !important; max-width: none !important; overflow: visible !important; font-size: 9.5px !important; }
    /* The wide "Summary" button took a third of the row: stacked like the tiles beside it. */
    .gstr7-topbar:has(.spq-abar.is-mobile) .slbs__track > button.btn { flex: 0 0 auto !important; display: inline-flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 44px; padding: 2px 3px !important; border: 0 !important; font-size: 9.5px !important; }
    .gstr7-topbar:has(.spq-abar.is-mobile) .slbs__track > button.btn > i { margin: 0 !important; font-size: 1.1rem; }
}

/* ===== GSTR-9 top bar (Gstr9TopBar.razor) ===== */
/* Ramesh (02-Nov-2026) — phone layout (UI only) of the GSTR-9 top bar. Before: the filing steps sat off screen
   behind the three data-source cards in one sideways scroller, the cards took ~75px, and the whole card (~200px) stayed
   stuck while scrolling. Now: row A = data source as one segmented row, row B = the steps as a full-width tile row + X;
   both scroll away, and only the part tabs stay pinned. Desktop untouched (only the new X). Lives in this module's own
   top bar, so it reaches only the GSTR-9 screens; gstr9.css, the grid and the shared components are not edited.
   Phones AND tablets (≤ 991.98px, the same breakpoint as gstr9.css's mobile pass): between 769 and 991px the desktop
   strip did not fit either — labels were cut ("Downloa", "Turnove") and the round buttons covered "More". */
@media (max-width: 991.98px) {
    /* Rows A + B: fixed heights so the sticky offset below is exact (6 + 48 + 6 + 66 + 6 = 132px).
       Row B is 66px so a three-line label ("Compare / Portal / Data") still fits inside it. */
    .gstr9-shell .gstr9-topbar > .stepstrip {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 32px;
        grid-template-rows: 48px 66px;
        row-gap: 6px;
        column-gap: 0;
        height: 132px;
        box-sizing: border-box;
        padding: 6px 6px !important;
        overflow: visible !important;
    }

    /* Row A — data source as one segmented control: equal segments, joined outline, dot hidden. */
    .gstr9-shell .gstr9-topbar > .stepstrip > .dsbar {
        grid-column: 1 / -1;
        grid-row: 1;
        display: flex !important;
        gap: 0 !important;
        overflow: visible !important;
        min-width: 0;
    }
    .gstr9-shell .gstr9-topbar > .stepstrip > .dsbar .ds-opt {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        min-height: 48px;
        margin: 0 0 0 -1px;
        padding: 3px 4px !important;
        border-radius: 0 !important;
        justify-content: center;
        text-align: center;
        white-space: normal !important;
    }
    .gstr9-shell .gstr9-topbar > .stepstrip > .dsbar .ds-opt:first-child { margin-left: 0; border-radius: 8px 0 0 8px !important; }
    .gstr9-shell .gstr9-topbar > .stepstrip > .dsbar .ds-opt:last-child { border-radius: 0 8px 8px 0 !important; }
    .gstr9-shell .gstr9-topbar > .stepstrip > .dsbar .ds-opt.active { position: relative; z-index: 1; }
    .gstr9-shell .gstr9-topbar > .stepstrip > .dsbar .ds-dot { display: none !important; }
    .gstr9-shell .gstr9-topbar > .stepstrip > .dsbar .ds-txt {
        display: flex; flex-direction: column; align-items: center;
        font-size: 12px !important; line-height: 1.15 !important;
    }
    .gstr9-shell .gstr9-topbar > .stepstrip > .dsbar .ds-txt em { font-size: 10px !important; line-height: 1.1 !important; }

    /* Row B — the filing steps: full width, equal tiles, two-line labels; X at its right. */
    .gstr9-shell .gstr9-topbar > .stepstrip > .steps {
        grid-column: 1;
        grid-row: 2;
        display: flex !important;
        min-width: 0 !important;
        width: auto !important;
        overflow: visible !important;
    }
    .gstr9-shell .gstr9-topbar > .stepstrip > .steps > .spq-abar.is-mobile { flex: 1 1 0% !important; min-width: 0; width: 100%; }
    .gstr9-shell .gstr9-topbar > .stepstrip > .go-back-close-btn {
        grid-column: 2;
        grid-row: 2;
        align-self: center;
        width: 32px; min-height: 44px;
    }

    /* Step dialogs live inside the bar's desktop row: keep it collapsed, not removed, so they still show. */
    .gstr9-shell .gstr9-topbar .steps .spq-abar.is-mobile .spq-abar__row {
        display: flex !important;
        height: 0 !important;
        min-height: 0 !important;
        width: 0 !important;
        min-width: 0 !important;
        flex: 0 0 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
    }
    .gstr9-shell .gstr9-topbar .steps .spq-abar.is-mobile .spq-abar__row :is(.modal, .modal-backdrop) { visibility: visible !important; }
    .gstr9-shell .gstr9-topbar .steps .spq-abar.is-mobile .spq-abar__sbtn[aria-label="Cancel"] { display: none !important; }
    .gstr9-shell .gstr9-topbar .steps .spq-abar.is-mobile .spq-abar__strip {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        width: 100%;
        border-bottom: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    .gstr9-shell .gstr9-topbar .steps .spq-abar.is-mobile .spq-abar__sbtn {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        width: auto !important;
        padding-left: 1px !important;
        padding-right: 1px !important;
    }
    .gstr9-shell .gstr9-topbar .steps .spq-abar.is-mobile .spq-abar__sblbl {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        max-width: none !important;
        line-height: 1.12 !important;
        text-align: center;
        font-size: 10px !important;
    }

    /* Only the part tabs stay pinned: the card is still sticky, but sticks 132px above the top, so
       rows A + B scroll away and the tabs (and the read-only notice, when shown) stay on screen. */
    .gstr9-shell > .gstr9-topbar-card:has(> .card-body > .gstr9-topbar) { top: -132px !important; }
    .gstr9-shell .gstr9-topbar .steps .spq-abar.is-mobile .spq-abar__sbtn { min-height: 66px; }

    /* Round Help / Bug / AI buttons sat over Settings / More of the sticky bottom bar: lift them above it,
       and hide them while a bottom sheet is open. */
    body:has(.gstr9-shell .gstr9-bottombar) :is(.ai-fab, .spq-bugwidget-fab, .spq-help-fab) {
        transform: translateY(-90px);
    }
    body:has(.gstr9-shell .spq-abar__sheet) :is(.ai-fab, .spq-bugwidget-fab, .spq-help-fab) {
        visibility: hidden !important;
    }
}

/* Desktop — room for the new close X. The steps bar was as wide as all its buttons and spilled out of its row,
   so it lay on top of the X (a click on X landed on "File GSTR-9"). Let it shrink to its row; its button row
   already scrolls sideways on desktop (gstr9.css, min-width 992px), and the X stays clickable above it. */
@media (min-width: 992px) {
    .gstr9-shell .gstr9-topbar > .stepstrip > .steps > .spq-abar { flex: 1 1 auto; min-width: 0; max-width: 100%; }
    .gstr9-shell .gstr9-topbar > .stepstrip > .go-back-close-btn { flex: 0 0 28px; align-self: center; position: relative; z-index: 2; }
}
/* Ramesh (06-Nov-2026): small phones - equal-width tiles were narrower than their label, so "Summary" / "Download" were cut and ran into the next tile. Each tile now takes the width of its own label. */
@media (max-width: 430px) {
    .gstr9-shell .gstr9-topbar .steps .spq-abar.is-mobile .spq-abar__sbtn { flex: 1 1 auto !important; min-width: min-content !important; width: auto !important; padding-left: 1px !important; padding-right: 1px !important; }
    .gstr9-shell .gstr9-topbar .steps .spq-abar.is-mobile .spq-abar__sbico { width: auto !important; min-width: 24px; }
    .gstr9-shell .gstr9-topbar .steps .spq-abar.is-mobile .spq-abar__sblbl { white-space: normal !important; word-break: normal !important; overflow-wrap: normal !important; hyphens: none !important; max-width: none !important; overflow: visible !important; }
}

/* ===== GSTR-9C top bar (Gstr9cTopBar.razor) ===== */
/* Ramesh (03-Nov-2026) — phones / tablets (≤991px), UI only. Before: only 6 tiles fitted, so both filing-status
   buttons and View Turnover sat in "More", labels were cut ("Upload JSON /", "Instructio"), the whole header stayed
   pinned, and the round Help / Bug / AI buttons covered the footer's More. Now:
     row A — GSTR-9C status · GSTR-9 status (Step-1) as two wide chips, X at the right;
     row B — Step-2 … Step-6, Instructions, View Turnover as equal tiles;
   both rows scroll away and only the part rail stays pinned. Clicks are untouched. Desktop untouched except the X. */
@media (max-width: 991.98px) {
    .gstr9c-shell .c9-stepbar {
        position: relative;
        display: block !important;
        padding: 4px 4px 2px !important;
        overflow: visible !important;
    }
    .gstr9c-shell .c9-stepbar > .spq-abar.is-mobile { width: 100%; margin: 0 !important; }
    .gstr9c-shell .c9-stepbar .spq-abar.is-mobile .spq-abar__strip {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 4px 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        border: 0 !important;
    }

    /* Row B — the step tiles: 7 to a row, labels on up to two lines, never cut. */
    .gstr9c-shell .c9-stepbar .spq-abar.is-mobile .spq-abar__sbtn {
        flex: 1 1 calc(100% / 7) !important;
        min-width: 0 !important;
        max-width: none !important;
        min-height: 58px !important;
        padding: 4px 1px !important;
        gap: 3px !important;
    }
    .gstr9c-shell .c9-stepbar .spq-abar.is-mobile .spq-abar__sblbl {
        font-size: 10px !important;
        line-height: 1.15 !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        display: block !important;
        -webkit-line-clamp: unset !important;
        max-width: 100% !important;
        word-break: normal;
        overflow-wrap: normal;
        letter-spacing: -0.2px;
        text-align: center;
    }
    .gstr9c-shell .c9-stepbar .spq-abar.is-mobile .spq-abar__sbtn:not([aria-label^="GSTR-9"]) .spq-abar__sblbl { font-size: 9.5px !important; }

    /* Row A — the two filing-status buttons ("GSTR-9C-…", "GSTR-9-…"; no step label starts with "GSTR-9")
       first, as wide chips: icon left of the text. Together they leave 40px for the X. */
    .gstr9c-shell .c9-stepbar .spq-abar.is-mobile .spq-abar__sbtn[aria-label^="GSTR-9"] {
        order: -1;
        flex: 0 0 calc(50% - 20px) !important;
        min-height: 44px !important;
        flex-direction: row !important;
        justify-content: flex-start !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 4px 8px !important;
        border: 1px solid var(--bd, #e2e8f0) !important;
        border-radius: 10px !important;
        background: var(--sf-card, #fff) !important;
    }
    /* GSTR-9C status first, then GSTR-9 (Step-1) — the desktop order. */
    .gstr9c-shell .c9-stepbar .spq-abar.is-mobile .spq-abar__sbtn[aria-label^="GSTR-9C"] {
        order: -2;
        margin-right: 4px;
        flex-basis: calc(50% - 24px) !important;
    }
    .gstr9c-shell .c9-stepbar .spq-abar.is-mobile .spq-abar__sbtn[aria-label^="GSTR-9"] .spq-abar__sblbl {
        font-size: 11.5px !important;
        text-align: left;
    }

    /* Close X at the right of row A, thumb-sized. */
    .gstr9c-shell .c9-stepbar > .go-back-close-btn {
        position: absolute;
        top: 4px;
        right: 4px;
        width: 34px;
        height: 44px;
        z-index: 2;
    }

    /* Only the part rail stays pinned: the header is still sticky, but sticks the height of the step rows
       above the top, so rows A + B scroll away (121px with the status row, 73px without it). */
    .gstr9c-shell > .sticky-head:has(.c9-stepbar) { top: -73px !important; }
    .gstr9c-shell > .sticky-head:has(.c9-stepbar .spq-abar__sbtn[aria-label^="GSTR-9"]) { top: -121px !important; }

    /* Round Help / Bug / AI buttons sat over the footer's More: lift them above it, and hide them while a
       bottom sheet is open. */
    body:has(.gstr9c-shell .gstr9c-bottombar) :is(.ai-fab, .spq-bugwidget-fab, .spq-help-fab) {
        transform: translateY(-90px);
    }
    body:has(.gstr9c-shell .spq-abar__sheet) :is(.ai-fab, .spq-bugwidget-fab, .spq-help-fab) {
        visibility: hidden !important;
    }
    /* Ramesh (03-Nov-2026): the footer is sticky with z-index 19, so its "More" sheet was trapped under the app's
       bottom tab bar (z 1040) and the last row, Delete, could not be seen or tapped. Lift the footer only while
       its sheet is open, staying under the side drawer (z 1045). */
    .gstr9c-shell .gstr9c-bottombar:has(.spq-abar__sheet) {
        z-index: 1044 !important;
    }
}

/* Ramesh (04-Nov-2026): small phones (360px) — "Instructions" was cut and "View Turnover" touched the edge.
   Slightly smaller step labels and a 2px inset at both ends of the row. */
@media (max-width: 400px) {
    .gstr9c-shell .c9-stepbar .spq-abar.is-mobile .spq-abar__strip { padding: 0 2px !important; }
    .gstr9c-shell .c9-stepbar .spq-abar.is-mobile .spq-abar__sbtn:not([aria-label^="GSTR-9"]) .spq-abar__sblbl {
        font-size: 8.5px !important;
        letter-spacing: -0.3px;
    }
    .gstr9c-shell .c9-stepbar .spq-abar.is-mobile .spq-abar__sbtn[aria-label^="GSTR-9"] .spq-abar__sblbl { font-size: 10.5px !important; }
}

/* Desktop — the X at the right end of the step row. */
@media (min-width: 992px) {
    .gstr9c-shell .c9-stepbar { flex-wrap: nowrap !important; }
    .gstr9c-shell .c9-stepbar > .spq-abar { flex: 1 1 auto; min-width: 0; }
    .gstr9c-shell .c9-stepbar > .go-back-close-btn { flex: 0 0 28px; align-self: flex-start; margin-top: 4px; }
}

/* ===== Table 8A top bar (Table8aTopBar.razor) ===== */
/* Ramesh (03-Nov-2026) — phone/tablet layout (UI only) of the Table 8A middle bar, same look as the other
   modules: ONE full-width row of equal tiles (icon above a short label) with the X at the right, and the
   last-download / last-upload time on a thin line under it. Before, only "Download Table 8A" fitted; Upload,
   Verify GSTINs, Excel and Portal File were off screen behind a ">" arrow. Only the look changes — every click,
   the file input and the dialogs are the same elements as before. Applies only while the bar is in its phone
   mode (GstActionBar .is-mobile, ≤991px); desktop untouched. */
.t8a-mcap { display: none; }

@media (max-width: 991.98px) {
    /* Room under the content so it ends above the round Help / Bug / AI buttons. */
    body:has(.t8a-topbar) .root-container {
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    }
    /* Help / Bug / AI buttons sat over the Excel / Clear sheet — hide them while it is open. */
    body:has(.t8a-topbar .spq-abar__sheet) :is(.ai-fab, .spq-bugwidget-fab, .spq-help-fab) {
        visibility: hidden !important;
    }

    .t8a-topbar:has(.spq-abar.is-mobile) {
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: 0 !important;
        padding: 2px 0 0 !important;
    }
    /* The scroller and its track step aside, so every button becomes one tile of the same row. */
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs,
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track { display: contents !important; }
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__nav,
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs::before,
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs::after { display: none !important; }
    /* Verify GSTINs' login-dialog host: kept (its dialog opens from here), takes no room. */
    .t8a-topbar:has(.spq-abar.is-mobile) .spq-provider-login-gate-container {
        flex: 0 0 0 !important; width: 0 !important; min-width: 0 !important; margin: 0 !important; padding: 0 !important;
    }

    /* Every tile the same width. */
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > :is(.spq-lb, .d-inline-flex.flex-column, .spq-ab, a.btn, .spq-abar),
    .t8a-topbar:has(.spq-abar.is-mobile) > .spq-abar {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        width: auto !important;
        margin: 0 !important;
        align-self: stretch !important;
    }
    .t8a-topbar .spq-abar.is-mobile .spq-abar__strip {
        width: 100%; height: 100%;
        padding: 0 !important; border: 0 !important; gap: 0 !important;
    }
    .t8a-topbar .spq-abar.is-mobile .spq-abar__sbtn { flex: 1 1 0 !important; min-width: 0 !important; width: 100% !important; padding: 4px 1px !important; }
    .t8a-topbar .spq-abar.is-mobile .spq-abar__sblbl {
        white-space: normal !important; overflow: visible !important; text-overflow: clip !important;
        max-width: none !important; line-height: 1.15 !important; text-align: center; font-size: 10px !important;
    }

    /* Download / Upload / Verify / Portal File: drawn like the strip tiles — icon above a two-line label. */
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > .spq-lb > .spq-ab,
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > .d-inline-flex.flex-column > label.btn,
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > .spq-ab,
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > a.btn {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px;
        width: 100% !important;
        height: 100%;
        min-height: 52px !important;
        margin: 0 !important;
        padding: 4px 1px !important;
        border: 0 !important;
        border-radius: 8px !important;
        background: transparent !important;
        box-shadow: none !important;
        color: var(--tc-text, #334155) !important;
        font-size: 10px !important;
        line-height: 1.15 !important;
        text-align: center;
        white-space: normal !important;
    }
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track .spq-ab__main {
        display: flex !important; flex-direction: column !important; align-items: center !important;
        gap: 3px; font-size: 10px !important; line-height: 1.15 !important; white-space: normal !important;
    }
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track .spq-ab__label { white-space: normal !important; overflow: visible !important; }
    /* Icon box and label exactly as the strip tiles draw theirs (gst-action-buttons.css .spq-abar__sbico / __sblbl). */
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > .spq-lb > .spq-ab i,
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > .d-inline-flex.flex-column > label.btn > i,
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > .spq-ab i,
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > a.btn > i {
        display: grid !important; place-items: center;
        width: 34px; height: 26px; margin: 0 !important;
        font-size: 1.25rem !important; line-height: 1 !important;
    }
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > .spq-lb > .spq-ab i,
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > .spq-ab i { color: var(--ab-tone-text); }
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > .d-inline-flex.flex-column > label.btn > i { color: var(--bs-info-text-emphasis, #087990); }
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > :is(.spq-lb, .d-inline-flex.flex-column) > :is(.spq-ab, label.btn),
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > :is(.spq-ab, a.btn) {
        gap: 3px !important;
        font-weight: clamp(1, calc(600 + var(--spq-fw-delta, 0)), 1000) !important;
        color: var(--tc-strong, #1f2937) !important;
    }
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > :is(.spq-lb, .d-inline-flex.flex-column) > :is(.spq-ab:active, label.btn:active),
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > :is(.spq-ab, a.btn):active { background: var(--sf-subtle, #f1f5f9) !important; }
    /* The captions move to the line below the row. */
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > .spq-lb .spq-ab__cap,
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > .d-inline-flex.flex-column > small { display: none !important; }
    /* "notes" badge (only after an import with notes): small, beside the tiles. */
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > span.align-self-center { flex: 0 0 auto; align-self: center !important; }

    /* X at the far right, thumb-sized. */
    .t8a-topbar:has(.spq-abar.is-mobile) > .go-back-close-btn { flex: 0 0 30px !important; width: 30px; min-height: 44px; align-self: center !important; }

    .t8a-topbar:has(.spq-abar.is-mobile) + .t8a-mcap {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0 12px;
        padding: 0 4px 4px;
        font-size: 10.5px;
        line-height: 1.3;
        color: var(--tc-muted, #64748b);
    }

    /* Grid "Column visibility & settings" gear not needed on phones (same as the return modules).
       Hidden from here, not in SmartGrid, so it only goes away on the Table 8A screens. */
    body:has(.t8a-topbar) .smartgrid-header .slbs__track > .flex-shrink-0:has(> .btn-group > button[title^="Column visibility"]) {
        display: none !important;
    }
}
/* Narrow phones (360px): ~40px tiles, so the labels go a touch smaller and "Download" still fits. */
@media (max-width: 389.98px) {
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track :is(.spq-ab__main, label.btn),
    .t8a-topbar:has(.spq-abar.is-mobile) .slbs__track > a.btn,
    .t8a-topbar .spq-abar.is-mobile .spq-abar__sblbl { font-size: 9px !important; letter-spacing: -0.3px; }
    .t8a-topbar:has(.spq-abar.is-mobile) > .go-back-close-btn { flex-basis: 26px !important; width: 26px; }
}

/* ===== E-Invoice GSTR-1 top bar (EInvGstr1TopBar.razor) ===== */
/* Ramesh (30-Oct-2026) — phone fixes (UI only) for the E-Invoice (GSTR-1) action row. Same look as the
   GSTR-1 pages. Lives in this module's own top bar, so it reaches only the e-invoice screens and only while
   one of them is open; header, grid and desktop layout untouched. */
@media (max-width: 768px) {
    /* Room under the grid so its last rows and "Total of All Pages" end above the round
       Help / Bug / AI buttons instead of underneath them. */
    body:has(.einv-toolbar) .root-container {
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* One full-width row: tiles, the E-Invoice Status picker, then Delete as the last tile.
       Before, "Download" was cut off, hidden scroll arrows and the X took room, and the
       divider line stopped short of Delete. */
    .einv-toolbar:has(.spq-abar.is-mobile) {
        flex-wrap: nowrap !important;
        gap: 0 !important;
        align-items: stretch !important;
        border-bottom: 1px solid var(--bd, #e7ecf3);
    }

    .einv-toolbar:has(.spq-abar.is-mobile) .slbs { flex: 1 1 0% !important; min-width: 0 !important; width: auto !important; }
    .einv-toolbar:has(.spq-abar.is-mobile) .slbs__nav,
    .einv-toolbar:has(.spq-abar.is-mobile) .slbs::before,
    .einv-toolbar:has(.spq-abar.is-mobile) .slbs::after { display: none !important; }
    .einv-toolbar:has(.spq-abar.is-mobile) .slbs__track {
        overflow: visible !important;
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
    }
    .einv-toolbar:has(.spq-abar.is-mobile) .slbs__track > .spq-abar { flex: 1 1 0%; min-width: 0; }

    /* Verify GSTINs popup on phones. The bar hides its desktop row on phones, and the Verify
       button keeps its choice popup (and confirm / login dialogs) inside that row, so the popup
       would open invisibly and its "Cancel" button would leak into the tile row. Keep the row
       collapsed and invisible instead of removed, so a popup opened from it can still show. */
    .einv-toolbar .spq-abar.is-mobile .spq-abar__row {
        display: flex !important;
        height: 0 !important;
        min-height: 0 !important;
        /* this bar lays out side by side, so the hidden row must not take width either */
        width: 0 !important;
        min-width: 0 !important;
        flex: 0 0 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
    }
    .einv-toolbar .spq-abar.is-mobile .spq-abar__row :is(.modal, .modal-backdrop) { visibility: visible !important; }
    .einv-toolbar .spq-abar.is-mobile .spq-abar__sbtn[aria-label="Cancel"] { display: none !important; }

    .einv-toolbar .spq-abar.is-mobile .spq-abar__strip {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        width: 100%;
        border-bottom: 0 !important;
        padding-left: 2px !important;
        padding-right: 2px !important;
    }
    .einv-toolbar .spq-abar.is-mobile .spq-abar__sbtn {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        width: auto !important;
        padding-left: 1px !important;
        padding-right: 1px !important;
    }
    /* Two-line labels instead of cut ones. */
    .einv-toolbar .spq-abar.is-mobile .spq-abar__sblbl {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        max-width: none !important;
        line-height: 1.15 !important;
        text-align: center;
        font-size: 10.5px !important;
    }

    /* E-Invoice Status: compact, beside the tiles. */
    .einv-toolbar:has(.spq-abar.is-mobile) .einv-status { flex: 0 0 108px; min-width: 0; }
    .einv-toolbar:has(.spq-abar.is-mobile) .einv-status label { font-size: 9px; }
    .einv-toolbar:has(.spq-abar.is-mobile) .einv-status select { min-width: 0; width: 100%; height: 36px; }

    /* Delete as a tile, then the X (go back) at the far right — kept on phones as requested. */
    .einv-toolbar:has(.spq-abar.is-mobile) > .ms-auto { margin-left: 0 !important; flex: 0 0 auto; min-width: 0; display: flex; align-items: center !important; gap: 0 !important; }
    .einv-toolbar:has(.spq-abar.is-mobile) > .ms-auto > .spq-abar { flex: 0 0 54px; width: 54px; min-width: 0; }
    .einv-toolbar:has(.spq-abar.is-mobile) > .ms-auto > .go-back-close-btn { flex: 0 0 36px; width: 36px; min-height: 44px; }
}
/* Ramesh (06-Nov-2026): small phones - equal-width tiles were narrower than their label, so "Summary" / "Download" were cut and ran into the next tile. Each tile now takes the width of its own label. */
@media (max-width: 430px) {
    .einv-toolbar .spq-abar.is-mobile .spq-abar__sbtn { flex: 1 1 auto !important; min-width: min-content !important; width: auto !important; padding-left: 1px !important; padding-right: 1px !important; }
    .einv-toolbar .spq-abar.is-mobile .spq-abar__sbico { width: auto !important; min-width: 24px; }
    .einv-toolbar .spq-abar.is-mobile .spq-abar__sblbl { white-space: normal !important; word-break: normal !important; overflow-wrap: normal !important; hyphens: none !important; max-width: none !important; overflow: visible !important; }
    /* Two tile groups shared the row equally; each now takes what its own tiles need. */
    .einv-toolbar:has(.spq-abar.is-mobile) .slbs__track > .spq-abar { flex: 1 1 auto !important; }
}

/* ===== E-Way Bill header bar (EwbHeaderBar.razor) ===== */
/* Ramesh (02-Nov-2026) — phone fixes (UI only) for the E-Way Bill middle bar: ONE full-width row — the four
   tabs as a compact segmented pill, a thin divider, then "Download EWB Data" as a tile. Before, B2C Large and Download
   were off screen behind a ">" arrow. Only how the buttons look changes; their clicks are untouched. Desktop untouched. */
@media (max-width: 768px) {
    /* Room under the grid so its last rows end above the round Help / Bug / AI buttons. */
    body:has(.ewb-topbar) .root-container {
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .ewb-topbar {
        padding: 4px !important;
        gap: 0 !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
    }
    /* Close X at the far right, thumb-sized. */
    .ewb-topbar > .go-back-close-btn { flex: 0 0 32px; width: 32px; min-height: 44px; }
    .ewb-topbar .slbs { flex: 1 1 0% !important; min-width: 0 !important; width: 100% !important; }
    .ewb-topbar .slbs__nav,
    .ewb-topbar .slbs::before,
    .ewb-topbar .slbs::after { display: none !important; }
    .ewb-topbar .slbs__track {
        overflow: visible !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: 0 !important;
    }

    /* The four tabs (every button before the divider) → equal segments, joined outline, labels wrap. */
    .ewb-topbar .slbs__track > .spq-ab:not(.vr ~ .spq-ab) {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        min-height: 48px !important;
        margin: 0 0 0 -1px !important;
        padding: 2px 3px !important;
        border-radius: 0 !important;
        white-space: normal !important;
    }
    .ewb-topbar .slbs__track > .spq-ab:first-child { margin-left: 0 !important; border-radius: 8px 0 0 8px !important; }
    .ewb-topbar .slbs__track > .spq-ab:not(.vr ~ .spq-ab):has(+ .vr),
    .ewb-topbar .slbs__track > .spq-ab:not(.vr ~ .spq-ab):last-child { border-radius: 0 8px 8px 0 !important; }
    .ewb-topbar .slbs__track > .spq-ab:not(.vr ~ .spq-ab) .spq-ab__main {
        display: flex !important;
        justify-content: center;
        align-items: center;
        font-size: 11px !important;
        line-height: 1.1 !important;
        text-align: center;
        white-space: normal !important;
        letter-spacing: 0 !important;
    }
    .ewb-topbar .slbs__track > .spq-ab:not(.vr ~ .spq-ab) .spq-ab__main i { display: none !important; }
    /* The open tab (rendered as Primary by this bar) filled, as in the other modules' tab pills. */
    .ewb-topbar .slbs__track > .spq-ab--primary:not(.vr ~ .spq-ab) {
        background: var(--theme-default, #3b4cb8) !important;
        border-color: var(--theme-default, #3b4cb8) !important;
        position: relative;
        z-index: 1;
    }
    .ewb-topbar .slbs__track > .spq-ab--primary:not(.vr ~ .spq-ab),
    .ewb-topbar .slbs__track > .spq-ab--primary:not(.vr ~ .spq-ab) .spq-ab__main { color: #fff !important; }

    /* Divider between the tabs and Download. */
    .ewb-topbar .slbs__track > .vr { align-self: stretch !important; height: auto !important; margin: 4px 4px !important; }

    /* Download EWB Data → a tile: icon above a two-line label. */
    .ewb-topbar .slbs__track > .vr ~ .spq-ab {
        flex: 0 0 74px !important;
        min-height: 48px !important;
        padding: 2px 2px !important;
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }
    .ewb-topbar .slbs__track > .vr ~ .spq-ab .spq-ab__main {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center;
        gap: 3px !important;
        font-size: 10.5px !important;
        line-height: 1.1 !important;
        text-align: center;
        white-space: normal !important;
    }
    .ewb-topbar .slbs__track > .vr ~ .spq-ab .spq-ab__main i { margin: 0 !important; font-size: 18px !important; }

    /* Grid "Column visibility & settings" gear not needed on phones (same as the return modules).
       Hidden from here, not in SmartGrid, so it only goes away on the E-Way Bill screens. */
    body:has(.ewb-topbar) .smartgrid-header .slbs__track > .flex-shrink-0:has(> .btn-group > button[title^="Column visibility"]) {
        display: none !important;
    }
}

/* ===== Purchase Register top bar (PurchaseRegisterTopBar.razor) ===== */
/* Ramesh (03-Nov-2026) — phone/tablet layout (UI only) of the Purchase Register middle bar. Before, one
   sideways-scrolling line showed only the section tabs; Import, Template, Export, Delete and Reconciliation were off
   screen behind a ">" arrow. Now ONE row: the action tiles (Summary first on a section page, as on GSTR-2A) with
   the X at the right; the sections are switched from the app's bottom nav (04-Nov-2026: section tabs hidden here). Only how the buttons look changes; every click, link and
   dialog is the same element as before. Applies only while the bar is in phone mode (GstActionBar .is-mobile);
   title bar, grid and desktop untouched. */
@media (max-width: 991.98px) {
    /* Room under the grid so its last rows end above the round Help / Bug / AI buttons. */
    body:has(.pr-topbar) .root-container {
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    }
    /* Help / Bug / AI buttons sat over the Export / More sheet — hide them while it is open. */
    body:has(.pr-topbar .spq-abar__sheet) :is(.ai-fab, .spq-bugwidget-fab, .spq-help-fab) {
        visibility: hidden !important;
    }

    .pr-topbar:has(.spq-abar.is-mobile) {
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 4px 0 !important;
        padding: 4px 0 0 !important;
        border-bottom: 1px solid var(--bd, #e7ecf3);
    }
    /* The scroller and its track step aside, so the tabs, the X and the action bar lay out as rows. */
    .pr-topbar:has(.spq-abar.is-mobile) .slbs,
    .pr-topbar:has(.spq-abar.is-mobile) .slbs__track { display: contents !important; }
    .pr-topbar:has(.spq-abar.is-mobile) .slbs__nav,
    .pr-topbar:has(.spq-abar.is-mobile) .slbs::before,
    .pr-topbar:has(.spq-abar.is-mobile) .slbs::after { display: none !important; }
    /* The desktop "← Summary" link is replaced by the Summary tile; the dividers have no job here. */
    .pr-topbar:has(.spq-abar.is-mobile) .slbs__track > :is(a.btn, .vr) { display: none !important; }

    /* Ramesh (04-Nov-2026): the B2B / Credit-Debit / Import of Goods tabs are hidden on phones — the app's
       bottom nav already has Summary / B2B / CDN / IMPG, so they showed twice. Desktop keeps them. */
    .pr-topbar:has(.spq-abar.is-mobile) .slbs__track > .btn-group { display: none !important; }

    /* One row — the action tiles take the width, equal, two-line labels; the X at their right. */
    .pr-topbar .slbs__track > .spq-abar.is-mobile {
        order: 1;
        flex: 1 1 0% !important;
        width: auto !important;
        min-width: 0;
        margin: 0 !important;
    }
    .pr-topbar:has(.spq-abar.is-mobile) > .go-back-close-btn {
        order: 2;
        flex: 0 0 30px !important;
        width: 30px;
        min-height: 44px;
        align-self: center !important;
    }
    /* Desktop row kept collapsed, not removed, so a popup opened from it can still show. */
    .pr-topbar .spq-abar.is-mobile .spq-abar__row {
        display: flex !important;
        height: 0 !important; min-height: 0 !important;
        width: 0 !important; min-width: 0 !important;
        flex: 0 0 0 !important;
        margin: 0 !important; padding: 0 !important; border: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
    }
    .pr-topbar .spq-abar.is-mobile .spq-abar__row :is(.modal, .modal-backdrop) { visibility: visible !important; }
    .pr-topbar .spq-abar.is-mobile .spq-abar__sbtn[aria-label="Cancel"] { display: none !important; }
    .pr-topbar .spq-abar.is-mobile .spq-abar__strip {
        width: 100%;
        margin-bottom: 0 !important;
        border-bottom: 0 !important;
        padding-left: 2px !important;
        padding-right: 2px !important;
    }
    .pr-topbar .spq-abar.is-mobile .spq-abar__sbtn {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        width: auto !important;
        padding-left: 1px !important;
        padding-right: 1px !important;
    }
    .pr-topbar .spq-abar.is-mobile .spq-abar__sblbl {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        max-width: none !important;
        line-height: 1.15 !important;
        text-align: center;
        font-size: 10.5px !important;
    }

    /* Grid "Column visibility & settings" gear not needed on phones (same as the return modules).
       Hidden from here, not in SmartGrid, so it only goes away on the Purchase Register screens. */
    body:has(.pr-topbar) .smartgrid-header .slbs__track > .flex-shrink-0:has(> .btn-group > button[title^="Column visibility"]) {
        display: none !important;
    }
}

/* Ramesh (03-Nov-2026): phones — the grid's own header in ONE row (Ramesh asked):
   [Refresh][Excel][PDF] [ search box ] [Advanced search][Date]. The search box sits in what was the empty space
   beside PDF and takes all the width left; its column picker shrinks to a narrow "All…" box (tap still opens the
   full list) and the ✕ shows only once something is typed. Only positions and widths change, from this
   module's CSS (not SmartGrid), so only the Purchase Register screens. */
@media (max-width: 767.98px) {
    body:has(.pr-topbar) .smartgrid-header {
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 4px !important;
    }
    body:has(.pr-topbar) .smartgrid-header > .smartgrid-btn-scroller {
        order: 1;
        flex: 0 0 auto !important;
        width: auto !important;
        min-width: 0 !important;
    }
    body:has(.pr-topbar) .smartgrid-header > .smartgrid-btn-scroller .slbs__nav,
    body:has(.pr-topbar) .smartgrid-header > .smartgrid-btn-scroller::before,
    body:has(.pr-topbar) .smartgrid-header > .smartgrid-btn-scroller::after { display: none !important; }
    body:has(.pr-topbar) .smartgrid-header > .smartgrid-btn-scroller .slbs__track { overflow: visible !important; }
    body:has(.pr-topbar) .smartgrid-header .grid-search-cluster {
        order: 2;
        flex: 1 1 0% !important;
        min-width: 0 !important;
        width: auto !important;
        gap: 4px !important;
        margin: 0 !important;
    }
    body:has(.pr-topbar) .smartgrid-header .grid-search-pill {
        flex: 1 1 0% !important;
        flex-wrap: nowrap !important;
        min-width: 0 !important;
        width: auto !important;
    }
    /* Refresh / PDF a little narrower (still 44px tall) to leave the search box more room to type. */
    body:has(.pr-topbar) .smartgrid-header > .smartgrid-btn-scroller :is(.refresh, .sg-pdf-btn) {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    body:has(.pr-topbar) .smartgrid-header .grid-search-pill > .grid-search-scope {
        flex: 0 0 46px !important;
        width: 46px !important;
        min-width: 0 !important;
        padding-left: 6px !important;
        padding-right: 14px !important;
        background-position: right 3px center !important;
        text-overflow: ellipsis;
    }
    body:has(.pr-topbar) .smartgrid-header .grid-search-pill > input {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        width: auto !important;
        padding-left: 6px !important;
        padding-right: 4px !important;
    }
    body:has(.pr-topbar) .smartgrid-header .grid-search-pill:has(> input:placeholder-shown) > .grid-search-clear { display: none !important; }
    body:has(.pr-topbar) .smartgrid-header .grid-search-pill > .btn { flex: 0 0 auto !important; padding-left: 7px !important; padding-right: 7px !important; }
    body:has(.pr-topbar) .smartgrid-header .grid-filter-actions { flex: 0 0 auto !important; gap: 4px !important; }

}

/* Ramesh (03-Nov-2026): phones — PDF moves INTO the green Excel dropdown, as its 3rd option, to give its place to
   the search box. SmartGrid has no slot for a menu item, so its own PDF button (a sibling of the Excel group) is
   hidden while the menu is closed and, while it is open, drawn over a row reserved at the bottom of the menu,
   styled as a menu item. It is still SmartGrid's PDF button, so the click and the PDF it makes are exactly as
   before. The menu keeps Bootstrap's own (fixed) placement; the PDF row is tied to it with CSS anchor positioning,
   so it follows the menu and is not cut off by the grid's scroll boxes. A browser without anchor positioning
   skips this whole block and keeps the separate red PDF button, as before. */
@supports (anchor-name: --a) {
@media (max-width: 767.98px) {
    body:has(.pr-topbar) .smartgrid-header .btn-group-square > .btn-group > .dropdown-menu.show {
        anchor-name: --pr-xl-menu;
        min-width: 240px !important;
        padding-bottom: 44px !important;       /* the PDF row: 40px + 4px */
    }
    body:has(.pr-topbar) .smartgrid-header .btn-group-square > .btn-group > .dropdown-menu.show .dropdown-item {
        display: flex !important;
        align-items: center;
        min-height: 40px;
        white-space: nowrap;
    }
    body:has(.pr-topbar) .smartgrid-header .btn-group-square:not(:has(> .btn-group > .dropdown-menu.show)) > .sg-pdf-btn {
        display: none !important;
    }
    body:has(.pr-topbar) .smartgrid-header .btn-group-square:has(> .btn-group > .dropdown-menu.show) > .sg-pdf-btn {
        position: fixed !important;
        position-anchor: --pr-xl-menu;
        left: calc(anchor(left) + 5px);
        top: calc(anchor(bottom) - 45px);      /* bottom padding 4px + border 1px + row 40px */
        width: calc(anchor-size(width) - 10px);
        z-index: 1001;                           /* over the menu (1000) */
        height: 40px;
        margin: 0 !important;
        padding: 0 12px !important;
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        gap: .5rem;
        border: 0 !important;
        border-radius: 6px !important;
        background: transparent !important;
        box-shadow: none !important;
        color: var(--bs-dropdown-link-color, var(--tc-text, #212529)) !important;
        /* same look as the two Excel rows above it (SmartGrid draws those at .6 opacity, normal weight) */
        opacity: .6;
        font-weight: clamp(1, calc(400 + var(--spq-fw-delta, 0)), 1000);
        font-size: 11px;
        text-align: left;
        white-space: nowrap;
    }
    body:has(.pr-topbar) .smartgrid-header .btn-group-square:has(> .btn-group > .dropdown-menu.show) > .sg-pdf-btn::after {
        content: "Export Current Screen to PDF";
    }
    body:has(.pr-topbar) .smartgrid-header .btn-group-square:has(> .btn-group > .dropdown-menu.show) > .sg-pdf-btn:is(:hover, :active) {
        background: var(--bs-dropdown-link-hover-bg, var(--sf-subtle, #f1f5f9)) !important;
    }
}
}
/* Narrow phones (360px): one row would leave no room to type, so the search box takes its own full-width line
   under the tools — [Refresh][Excel][PDF] … [Advanced][Date] on top, search below. */
@media (max-width: 399.98px) {
    body:has(.pr-topbar) .smartgrid-header { flex-wrap: wrap !important; }
    body:has(.pr-topbar) .smartgrid-header .grid-search-cluster { display: contents !important; }
    body:has(.pr-topbar) .smartgrid-header .grid-filter-actions { order: 2; margin-left: auto !important; }
    body:has(.pr-topbar) .smartgrid-header .grid-search-pill { order: 3; flex: 0 0 100% !important; }
    body:has(.pr-topbar) .smartgrid-header .grid-search-pill > .grid-search-scope { flex-basis: 80px !important; width: 80px !important; }
}

/* Desktop: the phone-only Summary tile never shows in the desktop row — it keeps its own link. */
.pr-topbar .spq-ab.pr-phone-only { display: none !important; }
