:root {
    /* --stg-red: #006eff;
    --stg-red-dark: #003983; */
    --stg-red: #e10600;
    --stg-red-dark: #b10500;
    --stg-black: #111214;
    --stg-ink: #1d1e22;
    --stg-bg: #f3f4f6;
    --stg-border: #e4e6ea;
    --stg-muted: #6b7280;
    --stg-sidebar-width: 236px;
    --stg-pad: 1rem;              /* Inner padding of cards and table cells. */
    /* --bs-link-color-rgb: 225, 6, 0;
    --bs-link-hover-color-rgb: 177, 5, 0; */
    --bs-link-color-rgb: 225, 6, 0;
    --bs-link-hover-color-rgb: 177, 5, 0;
}

/* One step below the browser default: every rem-based size (Bootstrap included) tightens with it. */
html { font-size: 15px; }

body {
    color: var(--stg-ink);
    background: var(--stg-bg);
}

.text-stg { color: var(--stg-red); }

.btn-stg {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--stg-red);
    --bs-btn-border-color: var(--stg-red);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--stg-red-dark);
    --bs-btn-hover-border-color: var(--stg-red-dark);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--stg-red-dark);
    --bs-btn-active-border-color: var(--stg-red-dark);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--stg-red);
    --bs-btn-disabled-border-color: var(--stg-red);
    font-weight: 600;
}

.form-label { margin-bottom: .25rem; font-size: .875rem; font-weight: 600; }

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--stg-red);
    box-shadow: 0 0 0 .2rem rgba(225, 6, 0, .15);
}

.form-check-input:checked {
    background-color: var(--stg-red);
    border-color: var(--stg-red);
}

.alert { padding: .65rem .9rem; font-size: .9rem; }

@media (max-width: 767.98px) {
    /* Below 16px, iOS Safari zooms the page when a field gets focus. */
    .form-control, .form-select { font-size: 16px; }
}

/* ───────────── Public pages (landing, login) ───────────── */

.stg-public {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background:
        linear-gradient(115deg, transparent 0 78%, rgba(225, 6, 0, .9) 78% 84%, var(--stg-black) 84%) bottom / 100% 150px no-repeat,
        #fff;
}

.stg-public main { flex: 1; }

.stg-public-header {
    background: rgba(255, 255, 255, .92);
    border-bottom: 1px solid var(--stg-border);
}

.stg-brand {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--stg-black);
    text-decoration: none;
}

.stg-brand img { width: 40px; height: auto; }

.stg-public-footer {
    padding: .75rem 0;
    font-size: .8rem;
    color: var(--stg-muted);
}

.stg-hero { padding: 2.5rem 0 1.25rem; }

.stg-eyebrow {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: .6rem;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .25em;
    text-transform: uppercase;
    color: var(--stg-ink);
}

.stg-eyebrow::before {
    content: "";
    width: 1.75rem;
    height: 3px;
    background: var(--stg-red);
}

.stg-hero-title {
    font-size: clamp(1.7rem, 4vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1.12;
}

.stg-hero-lead {
    max-width: 34rem;
    font-size: 1.05rem;
    color: #4b5563;
}

.stg-features {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.4rem;
    margin: 1.1rem 0 0;
    padding: 0;
    list-style: none;
    font-size: .9rem;
    font-weight: 600;
}

.stg-features li { display: flex; align-items: center; gap: .4rem; }
.stg-features i { font-size: 1.2rem; color: var(--stg-red); }

.stg-hero-logo {
    width: min(100%, 250px);
    height: auto;
    filter: drop-shadow(0 14px 24px rgba(0, 0, 0, .15));
}

.stg-portal-choice {
    padding: 1.25rem 0 5rem;
    text-align: center;
}

.stg-portal-choice h2 {
    margin-bottom: .25rem;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -.02em;
}

.stg-portal-choice > p { margin-bottom: 1.25rem; }

.stg-portal-card {
    display: flex;
    align-items: center;
    gap: .9rem;
    height: 100%;
    padding: 1rem 1.1rem;
    color: var(--stg-black);
    text-decoration: none;
    background: #fff;
    border: 1px solid var(--stg-border);
    border-radius: .9rem;
    box-shadow: 0 8px 22px rgba(17, 18, 20, .08);
    transition: transform .15s ease, box-shadow .15s ease;
}

.stg-portal-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(17, 18, 20, .14);
}

.stg-portal-card strong { display: block; font-size: 1.2rem; font-weight: 800; }
.stg-portal-card span span { font-size: .9rem; color: var(--stg-muted); }
.stg-portal-card-icon { font-size: 2.1rem; color: var(--stg-red); }

.stg-portal-card-arrow {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1.1rem;
    color: #fff;
    background: var(--stg-red);
    border-radius: .6rem;
}

.stg-portal-card-dark {
    color: #fff;
    background: var(--stg-black);
    border-color: var(--stg-black);
    border-bottom: 3px solid var(--stg-red);
}

.stg-portal-card-dark:hover { color: #fff; }
.stg-portal-card-dark span span { color: #c9ccd3; }
.stg-portal-card-dark .stg-portal-card-icon { color: #fff; }

.stg-login {
    display: grid;
    place-items: center;
    padding: 2rem 1rem 5rem;
}

.stg-login-card {
    width: min(100%, 400px);
    padding: 1.5rem;
    background: #fff;
    border: 1px solid var(--stg-border);
    border-top: 4px solid var(--stg-red);
    border-radius: .9rem;
    box-shadow: 0 14px 40px rgba(17, 18, 20, .12);
}

.stg-login-card h1 { margin: .6rem 0 .25rem; font-size: 1.3rem; font-weight: 800; }
.stg-login-card p { font-size: .9rem; }

.stg-login-icon {
    display: inline-grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.4rem;
    color: #fff;
    background: var(--stg-red);
    border-radius: .7rem;
}

/* ───────────── Portal shell (sidebar + topbar) ───────────── */

.stg-portal { min-height: 100vh; }

.stg-sidebar {
    --bs-offcanvas-width: var(--stg-sidebar-width);
    --bs-offcanvas-bg: var(--stg-black);
    color: #e5e7eb;
    background: var(--stg-black);
    border-right: 3px solid var(--stg-red);
}

@media (min-width: 992px) {
    .stg-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--stg-sidebar-width);
        overflow-y: auto;
        /* Bootstrap forces .offcanvas-lg transparent at this width. */
        background-color: var(--stg-black) !important;
    }

    .stg-main { margin-left: var(--stg-sidebar-width); }
}

.stg-sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .9rem 1rem .6rem;
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1;
    color: #fff;
    text-decoration: none;
}

.stg-sidebar-brand:hover { color: #fff; }

/* The logo file has a white background, so it sits on a white badge. */
.stg-sidebar-brand img {
    width: 40px;
    height: auto;
    padding: 2px;
    background: #fff;
    border-radius: 50%;
}

.stg-sidebar-brand small { font-size: .82rem; font-weight: 700; }
.stg-sidebar-brand em { font-style: italic; color: var(--stg-red); }

.stg-nav { padding: .25rem .6rem 1.5rem; }

.stg-nav-heading {
    margin: .9rem .65rem .3rem;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #9ca3af;
}

.stg-nav-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .45rem .7rem;
    margin-bottom: .1rem;
    font-size: .93rem;
    font-weight: 500;
    color: #e5e7eb;
    text-decoration: none;
    border-radius: .5rem;
}

.stg-nav-item i { font-size: 1rem; }
a.stg-nav-item:hover { color: #fff; background: rgba(255, 255, 255, .08); }

.stg-nav-item.active {
    font-weight: 700;
    color: #fff;
    background: linear-gradient(180deg, var(--stg-red), var(--stg-red-dark));
}

.stg-nav-item.disabled { color: #7b808a; cursor: default; }

.stg-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 52px;
    padding: .35rem var(--stg-pad);
    background: #fff;
    border-bottom: 1px solid var(--stg-border);
}

.stg-topbar-title {
    min-width: 0;
    margin: 0;
    padding-left: .65rem;
    overflow: hidden;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -.01em;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-left: 4px solid var(--stg-red);
}

.stg-user {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .2rem .35rem;
    font-size: .87rem;
    line-height: 1.2;
    background: none;
    border: 0;
    border-radius: .5rem;
}

.stg-user:hover { background: var(--stg-bg); }
.stg-user strong, .stg-user small { display: block; }
.stg-user small { color: var(--stg-muted); }

.stg-avatar {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.1rem;
    height: 2.1rem;
    font-size: .8rem;
    font-weight: 700;
    color: #fff;
    background: var(--stg-ink);
    border-radius: 50%;
}

.stg-content { padding: var(--stg-pad); }

/* ───────────── Cards and stats ───────────── */

.stg-card,
.stg-stat {
    background: #fff;
    border: 1px solid var(--stg-border);
    border-radius: .7rem;
    box-shadow: 0 1px 4px rgba(17, 18, 20, .05);
}

/* Safety net: wide content scrolls inside its card instead of pushing the page sideways. */
.stg-card { overflow-x: auto; }

.stg-stat {
    display: flex;
    align-items: center;
    gap: .7rem;
    height: 100%;
    min-width: 0;
    padding: .7rem .85rem;
}

.stg-stat > div { min-width: 0; }
.stg-stat small { display: block; font-size: .78rem; font-weight: 600; line-height: 1.25; color: var(--stg-muted); }
.stg-stat strong { font-size: 1.3rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }

.stg-stat-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.3rem;
    height: 2.3rem;
    font-size: 1.1rem;
    color: var(--stg-red);
    background: rgba(225, 6, 0, .08);
    border-radius: .55rem;
}

.stg-stat-accent { border-left: 4px solid var(--stg-red); }
a.stg-stat:hover { border-color: var(--stg-red); }

.stg-empty {
    padding: 2rem 1rem;
    text-align: center;
}

.stg-empty > i { font-size: 2rem; color: var(--stg-red); }
.stg-empty h2 { margin: .5rem 0 .3rem; font-size: 1.1rem; font-weight: 800; }
.stg-empty p { max-width: 32rem; margin: 0 auto; font-size: .9rem; color: var(--stg-muted); }

.stg-page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem 1rem;
    margin-bottom: .9rem;
}

.stg-page-head p { margin: 0; font-size: .9rem; color: var(--stg-muted); }

.stg-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .25rem .75rem;
    padding: .65rem var(--stg-pad);
    border-bottom: 1px solid var(--stg-border);
}

.stg-card-head h2 {
    margin: 0;
    padding-left: .55rem;
    font-size: .98rem;
    font-weight: 800;
    border-left: 3px solid var(--stg-red);
}

.stg-card-empty { margin: 0; padding: 1rem var(--stg-pad); font-size: .9rem; color: var(--stg-muted); }

.stg-inline-form {
    padding: .75rem var(--stg-pad);
    background: #fafafb;
    border-top: 1px solid var(--stg-border);
}

.stg-code {
    padding: .1rem .35rem;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--stg-ink);
    background: var(--stg-bg);
    border: 1px solid var(--stg-border);
    border-radius: .35rem;
}

.stg-label {
    margin-bottom: .15rem;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--stg-muted);
}

/* ───────────── Tables ───────────── */

.table { font-size: .9rem; }
.table > :not(caption) > * > * { padding: .5rem .6rem; }

.table thead th {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--stg-muted);
    white-space: nowrap;
}

.table td a { text-decoration: none; }
.table td a:hover { text-decoration: underline; }

.stg-card .table { margin-bottom: 0; }
.stg-card .table > :not(caption) > * > :first-child { padding-left: var(--stg-pad); }
.stg-card .table > :not(caption) > * > :last-child { padding-right: var(--stg-pad); }

.stg-table-card { padding: .75rem var(--stg-pad); }
.stg-table-card .table > :not(caption) > * > :first-child { padding-left: .6rem; }
.stg-table-card .table > :not(caption) > * > :last-child { padding-right: .6rem; }

/* DataTables controls */
.dt-container { font-size: .85rem; }
.dt-container .dt-layout-row { margin: .4rem 0 !important; }
.dt-container .dt-search input, .dt-container .dt-length select { font-size: .85rem; }

.page-item.active .page-link,
.active > .page-link {
    background-color: var(--stg-red);
    border-color: var(--stg-red);
}

.page-link { color: var(--stg-ink); }

/*
 * Phones and small tablets: a table with a header becomes a list of cards, one per row,
 * each cell on its own line with its column name (data-label, set by stg.js).
 */
@media (max-width: 767.98px) {
    table.stg-stack thead { display: none; }

    table.stg-stack,
    table.stg-stack tbody,
    table.stg-stack tr,
    table.stg-stack td { display: block; width: 100% !important; }

    table.stg-stack tr { padding: .55rem 0; border-bottom: 1px solid var(--stg-border); }
    table.stg-stack tbody tr:last-child { border-bottom: 0; }

    table.stg-stack td {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: .75rem;
        padding: .14rem var(--stg-pad) !important;
        border: 0;
        text-align: right;
        white-space: normal !important;
    }

    .stg-table-card table.stg-stack td { padding-left: .15rem !important; padding-right: .15rem !important; }

    table.stg-stack td::before {
        content: attr(data-label);
        flex: none;
        max-width: 42%;
        font-size: .7rem;
        font-weight: 700;
        text-align: left;
        text-transform: uppercase;
        letter-spacing: .03em;
        color: var(--stg-muted);
    }

    /* Columns without a title (checkbox, actions): no label, content stays to the right. */
    table.stg-stack td[data-label=""]::before { content: none; }
    table.stg-stack td[data-label=""] { justify-content: flex-end; }

    table.stg-stack .stg-cell { min-width: 0; overflow-wrap: anywhere; }
    table.stg-stack td.dt-empty { justify-content: center; text-align: center; color: var(--stg-muted); }
}

/* ───────────── Weekly timecard ───────────── */

.stg-week-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem .75rem;
    margin-bottom: .75rem;
}

.stg-week-nav { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.stg-week-nav .btn { flex: none; }
.stg-week-label { font-size: 1rem; font-weight: 800; line-height: 1.2; white-space: nowrap; }
.stg-week-actions { display: flex; gap: .5rem; }

/* Four totals in one compact strip. */
.stg-week-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: .75rem;
    overflow: hidden;
}

.stg-week-summary > div { padding: .55rem .75rem; border-left: 1px solid var(--stg-border); min-width: 0; }
.stg-week-summary > div:first-child { border-left: 0; }
.stg-week-summary small { display: block; font-size: .72rem; font-weight: 600; color: var(--stg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stg-week-summary strong { font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stg-week-summary .is-total { background: rgba(225, 6, 0, .06); }
.stg-week-summary .is-total strong { color: var(--stg-red-dark); }

.stg-day {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    border-bottom: 1px solid var(--stg-border);
}

.stg-day:last-child { border-bottom: 0; }
.stg-day-today .stg-day-head { box-shadow: inset 3px 0 0 var(--stg-red); }

.stg-day-head {
    display: flex;
    flex-direction: column;
    padding: .65rem .85rem;
    font-size: .9rem;
    background: #fafafb;
    border-right: 1px solid var(--stg-border);
}

.stg-day-head strong { text-transform: capitalize; }
.stg-day-head span { font-size: .8rem; color: var(--stg-muted); }
.stg-day-head .stg-day-total { margin-top: .2rem; font-size: .9rem; font-weight: 700; color: var(--stg-ink); font-variant-numeric: tabular-nums; }

.stg-day-body { padding: .3rem .85rem .45rem; min-width: 0; }

.stg-entry {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .45rem 0;
    font-size: .9rem;
    border-bottom: 1px dashed var(--stg-border);
}

.stg-entry-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.stg-entry-main .small { font-size: .8rem; }
.stg-entry-side { display: flex; align-items: center; gap: .6rem; flex: none; }
.stg-entry-hours { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stg-entry-actions { display: flex; gap: .3rem; }

.stg-add-entry {
    margin-top: .3rem;
    padding: .2rem 0;
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
}

/* Bottom bar with the week total and the submit button (phones only). */
.stg-week-bar { display: none; }

@media (max-width: 575.98px) {
    .stg-week-nav { width: 100%; justify-content: space-between; }
    .stg-week-nav .btn { width: 2.75rem; height: 2.75rem; padding: 0; }
    .stg-week-title { text-align: center; }
    .stg-week-actions { width: 100%; }
    .stg-week-actions .btn { flex: 1; }

    .stg-week-summary > div { padding: .45rem .5rem; text-align: center; }
    .stg-week-summary small { font-size: .66rem; }
    .stg-week-summary strong { font-size: .98rem; }

    .stg-day { grid-template-columns: minmax(0, 1fr); }

    .stg-day-head {
        flex-direction: row;
        align-items: baseline;
        gap: .45rem;
        padding: .5rem .75rem;
        border-right: 0;
        border-bottom: 1px solid var(--stg-border);
    }

    .stg-day-head .stg-day-total { margin: 0 0 0 auto; }
    .stg-day-body { padding: .15rem .75rem .6rem; }

    /* Hours on top, edit/delete below, both in thumb reach on the right. */
    .stg-entry { align-items: flex-start; }
    .stg-entry-side { flex-direction: column; align-items: flex-end; gap: .3rem; }
    .stg-entry-actions .btn { width: 2.6rem; height: 2.6rem; padding: 0; font-size: 1rem; }

    .stg-add-entry {
        display: block;
        width: 100%;
        min-height: 2.9rem;
        margin-top: .5rem;
        color: var(--stg-red-dark);
        background: rgba(225, 6, 0, .04);
        border: 1px dashed rgba(225, 6, 0, .45);
        border-radius: .55rem;
    }

    .stg-week-bar {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 20;
        display: flex;
        align-items: center;
        gap: .75rem;
        padding: .55rem .9rem calc(.55rem + env(safe-area-inset-bottom));
        background: #fff;
        border-top: 1px solid var(--stg-border);
        box-shadow: 0 -4px 14px rgba(17, 18, 20, .08);
    }

    .stg-week-bar small { display: block; font-size: .7rem; font-weight: 600; color: var(--stg-muted); }
    .stg-week-bar strong { font-size: 1.15rem; font-weight: 800; white-space: nowrap; }
    .stg-week-bar .btn { flex: 1; min-height: 2.9rem; }

    /* Room so the bar never covers the last day. */
    .stg-week-days { margin-bottom: 4.75rem; }
}

/* ───────────── Time entry form (modal) ───────────── */

.stg-interval {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: end;
    gap: .5rem;
    margin-bottom: .5rem;
}

.stg-interval label { min-width: 0; margin: 0; }
.stg-interval label span { display: block; margin-bottom: .15rem; font-size: .75rem; font-weight: 600; color: var(--stg-muted); }

@media (max-width: 575.98px) {
    .modal-header, .modal-footer { padding: .65rem .9rem; }
    .modal-body { padding: .9rem; }
    .modal-title { font-size: 1.05rem; }

    /* Full-width, thumb-sized controls in every modal form. */
    .modal-footer .btn { flex: 1; min-height: 2.9rem; }
    .js-entry-form .btn-group { display: flex; width: 100%; }
    .js-entry-form .btn-group .btn { flex: 1; min-height: 2.6rem; }
    .js-entry-form .form-control, .js-entry-form .form-select { min-height: 2.9rem; }
    .stg-interval .btn { width: 2.9rem; height: 2.9rem; padding: 0; }
}

/* ───────────── Approvals ───────────── */

.stg-pills { gap: .15rem; }
.stg-pills .nav-link { padding: .35rem .7rem; font-size: .88rem; font-weight: 600; color: var(--stg-ink); }
.stg-pills .nav-link.active { background: var(--stg-ink); color: #fff; }

.stg-timeline { margin: 0; padding: .85rem var(--stg-pad) .85rem 1.9rem; list-style: none; font-size: .9rem; }

.stg-timeline li {
    position: relative;
    padding: 0 0 .8rem .85rem;
    border-left: 2px solid var(--stg-border);
}

.stg-timeline li:last-child { padding-bottom: 0; }

.stg-timeline li::before {
    content: "";
    position: absolute;
    left: -6px;
    top: .35rem;
    width: 10px;
    height: 10px;
    background: var(--stg-red);
    border-radius: 50%;
}

/* ───────────── Client portal / audit ───────────── */

.stg-progress { background-color: var(--stg-red); }

.stg-audit-detail {
    display: block;
    max-width: 520px;
    max-height: 4.5em;
    overflow: auto;
    font-size: .72rem;
    color: var(--stg-ink);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ───────────── Small screens: shell and page chrome ───────────── */

@media (max-width: 575.98px) {
    :root { --stg-pad: .75rem; }

    .stg-topbar { min-height: 48px; }
    .stg-topbar-title { font-size: 1rem; }

    /* Page actions take the full row: easier to hit, and nothing sticks out. */
    .stg-page-head > .btn,
    .stg-page-head > form,
    .stg-page-head > .d-flex { width: 100%; }
    .stg-page-head > .d-flex > .btn { flex: 1; }

    .stg-stat { gap: .5rem; padding: .55rem .6rem; }
    .stg-stat-icon { width: 1.9rem; height: 1.9rem; font-size: .95rem; }
    .stg-stat strong { font-size: 1.1rem; }
    .stg-stat small { font-size: .72rem; }

    .stg-hero { padding: 1.5rem 0 .5rem; }
    .stg-login { padding: 1.25rem .75rem 4rem; }
    .stg-login-card { padding: 1.1rem; }
    .stg-brand { font-size: 1.05rem; }
    .stg-public { background-size: 100% 90px; }
}

/* DataTables controls on phones: just a full-width search box, close to the list. */
@media (max-width: 767.98px) {
    .dt-container .dt-length { display: none; }
    .dt-container .dt-layout-row { display: block; margin: .3rem 0 !important; }
    .dt-container .dt-layout-cell { display: block; padding: 0 !important; margin: 0 !important; }
    .dt-container .dt-search { display: flex; align-items: center; gap: .5rem; }
    .dt-container .dt-search input { flex: 1; min-width: 0; margin: 0 !important; }
    .dt-container .dt-info { padding: .25rem 0 !important; text-align: center; color: var(--stg-muted); }
    .dt-container .dt-paging { display: flex; justify-content: center; }
}

/* ───────────── Landing page sections ───────────── */

.stg-public-nav { gap: 1.4rem; }
.stg-public-nav a { font-size: .9rem; font-weight: 600; color: var(--stg-ink); text-decoration: none; }
.stg-public-nav a:hover { color: var(--stg-red); }

html { scroll-behavior: smooth; }
.stg-section, .stg-portal-choice { scroll-margin-top: 1rem; }

.stg-section { padding: 2.75rem 0; }
.stg-section-alt { background: var(--stg-bg); }
.stg-section-dark { color: #fff; background: var(--stg-black); }
.stg-section-dark .stg-eyebrow { color: #fff; }

.stg-section-title {
    margin-bottom: .4rem;
    font-size: clamp(1.3rem, 2.6vw, 1.75rem);
    font-weight: 800;
    letter-spacing: -.02em;
    text-align: center;
}

.stg-section-lead { max-width: 38rem; margin: 0 auto; color: var(--stg-muted); text-align: center; }
.stg-section .row, .stg-steps, .stg-faq .accordion { margin-top: 1.5rem; }
.stg-section-dark .row { margin-top: 0; }

.stg-feature, .stg-role {
    height: 100%;
    padding: 1.1rem;
    background: #fff;
    border: 1px solid var(--stg-border);
    border-radius: .8rem;
}

.stg-feature h3, .stg-role h3, .stg-steps h3 { margin: .6rem 0 .3rem; font-size: 1rem; font-weight: 800; }
.stg-feature p, .stg-steps p { margin: 0; font-size: .9rem; color: var(--stg-muted); }

.stg-feature-icon {
    display: inline-grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.2rem;
    color: var(--stg-red);
    background: rgba(225, 6, 0, .08);
    border-radius: .6rem;
}

.stg-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    padding: 0;
    list-style: none;
}

.stg-steps li { position: relative; padding-top: .25rem; }

/* The line that joins one step to the next. */
.stg-steps li:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 1.35rem;
    left: 3rem;
    right: -.25rem;
    height: 2px;
    background: var(--stg-border);
}

.stg-step-number {
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    font-weight: 800;
    color: #fff;
    background: var(--stg-red);
    border-radius: 50%;
}

.stg-role h3 { display: flex; align-items: center; gap: .5rem; margin-top: 0; }
.stg-role h3 i { font-size: 1.25rem; color: var(--stg-red); }
.stg-role ul { margin: .6rem 0 0; padding-left: 1.1rem; font-size: .9rem; color: #4b5563; }
.stg-role li { margin-bottom: .25rem; }

.stg-checks {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .6rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: .93rem;
}

.stg-checks li { display: flex; gap: .5rem; }
.stg-checks i { flex: none; color: var(--stg-red); }

.stg-faq { max-width: 760px; }
.stg-faq .accordion-button { font-size: .95rem; font-weight: 700; }
.stg-faq .accordion-button:not(.collapsed) { color: var(--stg-red-dark); background: rgba(225, 6, 0, .05); box-shadow: none; }
.stg-faq .accordion-button:focus { box-shadow: 0 0 0 .2rem rgba(225, 6, 0, .15); }
.stg-faq .accordion-body { font-size: .9rem; color: #4b5563; }

.stg-cta { padding: 2.5rem 0 6.5rem; text-align: center; }
.stg-cta h2 { margin-bottom: 1rem; font-size: 1.4rem; font-weight: 800; }

/* Hero illustration: a small, static picture of the weekly timecard. */
.stg-mock {
    max-width: 460px;
    margin: 0 auto;
    overflow: hidden;
    font-size: .82rem;
    background: #fff;
    border: 1px solid var(--stg-border);
    border-radius: .9rem;
    box-shadow: 0 18px 44px rgba(17, 18, 20, .14);
}

.stg-mock-bar { display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; color: #fff; background: var(--stg-black); }
.stg-mock-bar img { padding: 1px; background: #fff; border-radius: 50%; }
.stg-mock-pill { margin-left: auto; padding: .05rem .5rem; font-size: .7rem; background: rgba(255, 255, 255, .16); border-radius: 1rem; }
.stg-mock-summary { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--stg-border); }
.stg-mock-summary div { padding: .5rem .6rem; border-left: 1px solid var(--stg-border); }
.stg-mock-summary div:first-child { border-left: 0; }
.stg-mock-summary small { display: block; font-size: .66rem; color: var(--stg-muted); }
.stg-mock-summary strong { font-size: .95rem; }
.stg-mock-summary .is-total { background: rgba(225, 6, 0, .06); color: var(--stg-red-dark); }
.stg-mock-row { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem; border-bottom: 1px dashed var(--stg-border); }
.stg-mock-row:last-child { border-bottom: 0; }
.stg-mock-row span { flex: 1; min-width: 0; color: var(--stg-muted); }
.stg-mock-row b { display: block; color: var(--stg-ink); }

@media (max-width: 991.98px) {
    .stg-steps { grid-template-columns: repeat(2, 1fr); }
    .stg-steps li::after { display: none; }
}

@media (max-width: 575.98px) {
    .stg-section { padding: 2rem 0; }
    .stg-steps, .stg-checks { grid-template-columns: 1fr; }
    .stg-hero .btn-lg, .stg-cta .btn-lg { flex: 1; font-size: 1rem; }
    .stg-cta { padding-bottom: 5rem; }
}

/* ───────────── Sidebar collapsed to icons (desktop) ───────────── */

@media (min-width: 992px) {
    .stg-sidebar, .stg-main { transition: width .15s ease, margin-left .15s ease; }

    html.stg-sidebar-collapsed { --stg-sidebar-width: 60px; }

    html.stg-sidebar-collapsed .stg-sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
    html.stg-sidebar-collapsed .stg-sidebar-brand span { display: none; }
    html.stg-sidebar-collapsed .stg-nav { padding-left: .45rem; padding-right: .45rem; }

    /* Section titles become a divider line. */
    html.stg-sidebar-collapsed .stg-nav-heading {
        height: 1px;
        margin: .6rem .35rem;
        overflow: hidden;
        font-size: 0;
        background: rgba(255, 255, 255, .14);
    }

    /* Only the icon stays; the name is in the tooltip (title, set by stg.js). */
    html.stg-sidebar-collapsed .stg-nav-item { justify-content: center; gap: 0; padding: .55rem 0; font-size: 0; }
    html.stg-sidebar-collapsed .stg-nav-item i { font-size: 1.1rem; }
}

/* ───────────── Resource portal as a mobile app (phones) ───────────── */

.stg-tabbar { display: none; }

.stg-avatar-lg { width: 3rem; height: 3rem; font-size: 1.05rem; }

.stg-sheet { height: auto; border-radius: 1rem 1rem 0 0; }
.stg-sheet .offcanvas-body { padding: 1.1rem 1rem calc(1.1rem + env(safe-area-inset-bottom)); }

.stg-daystrip { display: none; }

@media (max-width: 767.98px) {
    /* App header: dark bar, centred title. Navigation and account move to the tab bar. */
    .stg-app .stg-topbar {
        justify-content: center;
        min-height: 50px;
        padding-top: calc(.35rem + env(safe-area-inset-top));
        background: var(--stg-black);
        border-bottom: 3px solid var(--stg-red);
    }

    .stg-app .stg-topbar-title { padding-left: 0; font-size: 1.05rem; color: #fff; border-left: 0; }
    .stg-app .stg-menu-btn, .stg-app .stg-user-menu { display: none !important; }

    .stg-app .stg-content { padding-bottom: calc(4.6rem + env(safe-area-inset-bottom)); }

    .stg-app .stg-tabbar {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 30;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        padding-bottom: env(safe-area-inset-bottom);
        background: #fff;
        border-top: 1px solid var(--stg-border);
        box-shadow: 0 -4px 14px rgba(17, 18, 20, .07);
    }

    .stg-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: .1rem;
        min-height: 3.6rem;
        padding: .45rem .25rem .35rem;
        font-size: .68rem;
        font-weight: 600;
        color: var(--stg-muted);
        text-decoration: none;
        background: none;
        border: 0;
    }

    .stg-tab i { font-size: 1.3rem; line-height: 1; }
    .stg-tab.active { color: var(--stg-red); }

    /* The submit bar sits right above the tab bar. */
    .stg-app .stg-week-bar { bottom: calc(3.6rem + env(safe-area-inset-bottom)); z-index: 25; padding-bottom: .55rem; }
    .stg-app .stg-week-days { margin-bottom: 4.5rem; }

    /* Messages and modals above the tab bar. */
    .stg-app .modal { z-index: 1060; }
}

@media (max-width: 575.98px) {
    /* Week: seven day chips; only the chosen day is listed below. */
    .stg-daystrip {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: .3rem;
        margin-bottom: .6rem;
    }

    .stg-daychip {
        display: flex;
        flex-direction: column;
        align-items: center;
        min-width: 0;
        padding: .35rem 0 .3rem;
        line-height: 1.15;
        color: var(--stg-ink);
        background: #fff;
        border: 1px solid var(--stg-border);
        border-radius: .65rem;
    }

    .stg-daychip small { font-size: .62rem; font-weight: 600; text-transform: uppercase; color: var(--stg-muted); }
    .stg-daychip strong { font-size: 1.05rem; font-weight: 800; }
    .stg-daychip span { font-size: .62rem; font-weight: 700; color: var(--stg-muted); white-space: nowrap; }

    .stg-daychip.is-today { border-color: var(--stg-red); }

    .stg-daychip.is-active { color: #fff; background: var(--stg-red); border-color: var(--stg-red); }
    .stg-daychip.is-active small, .stg-daychip.is-active span { color: rgba(255, 255, 255, .85); }

    .stg-week-list .stg-day:not(.is-active) { display: none; }
    .stg-week-list .stg-day { border-bottom: 0; }
}

/* ───────────── Account security pages ───────────── */

.stg-login-card-wide { width: min(100%, 480px); }

.stg-otp { font-size: 1.4rem; font-weight: 700; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }

.stg-setup-steps { margin: 0; padding-left: 1.2rem; font-size: .92rem; }
.stg-setup-steps li { margin-bottom: 1rem; }
.stg-setup-steps li::marker { font-weight: 800; color: var(--stg-red); }

.stg-qr { padding: .4rem; background: #fff; border: 1px solid var(--stg-border); border-radius: .6rem; }

.stg-shared-key {
    display: block;
    margin-top: .25rem;
    padding: .4rem .6rem;
    font-size: .95rem;
    color: var(--stg-ink);
    word-spacing: .3em;
    background: var(--stg-bg);
    border-radius: .4rem;
    user-select: all;
}

.stg-recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem; }

.stg-recovery-codes code {
    padding: .45rem;
    font-size: .95rem;
    color: var(--stg-ink);
    text-align: center;
    background: var(--stg-bg);
    border: 1px dashed var(--stg-border);
    border-radius: .4rem;
}

.stg-security-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--stg-border);
}

@media print {
    .stg-public-header, .stg-public-footer, .stg-login-card .btn { display: none !important; }
    .stg-login-card { box-shadow: none; border: 0; }
}

/* ── Attendance sheet (Approvals/Attendance) ── */
.stg-attendance-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: .9rem; }
.stg-attendance-filters .form-select { max-width: 360px; }
.stg-attendance th.is-today { color: var(--stg-red, #e10600); }
.stg-attendance td:first-child { min-width: 180px; }
.stg-att-input { width: 4.2rem; margin: 0 auto; text-align: center; }
.stg-att-value { display: inline-block; min-width: 2.5rem; font-weight: 600; }
.stg-att-ownhours, .stg-att-self { background: var(--bs-tertiary-bg); }
.stg-att-ownhours .stg-att-value { color: var(--stg-muted); }
.stg-attendance tfoot th { border-bottom: 0; }
.stg-attendance-foot { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; margin-top: .5rem; }

@media (max-width: 767.98px) {
    .stg-attendance-filters .form-select { max-width: none; }
    /* Stacked rows: each day is a line "Lun 10 [ input ]". */
    table.stg-stack.stg-attendance td.text-center { text-align: right !important; }
    .stg-att-input { margin: 0 0 0 auto; }
    .stg-attendance tfoot { display: none; }
    .stg-attendance-foot > .d-flex { width: 100%; }
    .stg-attendance-foot > .d-flex > .btn { flex: 1; }
}
