
.layout {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    backdrop-filter: blur(8px);
    border-right: 1px solid var(--card-border);
    padding: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    transition: width 0.24s ease, background-color 0.3s ease, border-color 0.3s ease;
}

    .sidebar .scroll {
        padding: 12px 8px 20px;
        overflow-y: auto;
        overflow-x: hidden;
        flex: 1;
        scrollbar-width: none; /* Firefox — hide scrollbar */
        -ms-overflow-style: none; /* IE / old Edge */
    }

        .sidebar .scroll::-webkit-scrollbar {
            display: none;
        }
/* Chrome / Safari / Edge */

.brand {
    display: flex;
    align-items: center;
    flex: 0 0 52px;
    height: 52px;
    padding: 0 16px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--card-border);
}

    .brand svg {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    /* Logo badge (the "TSS" mark) */
    .brand .mark {
        width: 22px;
        height: 22px;
        border-radius: 5px;
        background: var(--brand);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-family: 'Fraunces', serif;
        font-weight: 600;
        font-size: 11px;
        letter-spacing: 0.02em;
        flex-shrink: 0;
    }

    .brand .txt {
        font-family: 'Fraunces', serif;
        font-weight: 600;
        font-size: 13px;
        line-height: 1.18;
        letter-spacing: 0.01em;
        display: inline-block;
        margin-left: 9px;
        max-width: 168px;
        white-space: normal; /* wrap the full name instead of truncating with an ellipsis */
        overflow: hidden;
        transition: max-width 0.26s ease, opacity 0.2s ease, margin-left 0.26s ease;
    }

.nav-label {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted-dim);
    padding: 4px 8px 6px;
    margin: 10px 0 2px;
    white-space: nowrap;
}

    .nav-label .dots {
        display: none;
        text-align: center;
        letter-spacing: 0.15em;
    }

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 6px 8px;
    border-radius: 5px;
    font-size: 12.5px;
    color: var(--nav);
    background: none;
    border: none;
    text-align: left;
    transition: background 0.18s ease, color 0.18s ease;
    margin-bottom: 1px;
}

    .nav-item svg.ni {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
    }

    .nav-item .txt {
        white-space: nowrap;
    }

    .nav-item:hover {
        background: var(--hover);
        color: var(--text);
    }

    .nav-item.active {
        background: color-mix(in srgb, var(--brand) 13%, transparent);
        color: var(--brand);
    }

/* .badge-n (a count pill on a nav item) is gone — the nav draft counters it was
   built for were removed, and nothing has rendered one since. */

/* Submenu groups */
.nav-arrow {
    width: 14px;
    height: 14px;
    margin-left: auto;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.nav-group.open > .nav-parent .nav-arrow {
    transform: rotate(180deg);
}

/* Highlight the group parent when the current route is one of its children —
   full pill (background + blue text + blue icon), like TailAdmin.
   NavLink sets .active on the matching sub-link; :has() reacts automatically.

   This is the ONLY thing the route drives. Whether the submenu is open is a
   separate question owned entirely by .open (set in app.js) — see .nav-sub
   below for why the two must not both control it. */
/* .child-active was a second, JS-set way to express the same thing; nothing has
   ever set it and :has() does the job on its own. */
.nav-group:has(.nav-item.active) > .nav-parent {
    color: var(--brand);
    background: color-mix(in srgb, var(--brand) 13%, transparent);
}

.nav-sub {
    overflow: hidden;
    max-height: 0;
    padding-left: 18px;
    transition: max-height 0.28s ease;
}

/* .open is the single source of truth for "is this group expanded".

   This used to also open on :has(.nav-item.active), so the route forced a group
   open behind the accordion's back. The two disagreed: clicking the parent of the
   group you were already in flipped .open and the saved key but changed nothing on
   screen, because the :has rule held it open regardless — the button looked dead.
   app.js now opens the active group on navigation instead, which keeps the same
   behaviour without a second owner fighting the first.

   The ceiling is generous on purpose: Management already renders 163px of items,
   so the old 180px was one menu entry away from silently clipping the last link. */
.nav-group.open > .nav-sub {
    max-height: 420px;
}

.nav-sub .nav-item {
    font-size: 12.5px;
    padding: 5px 8px;
}

    .nav-sub .nav-item::before {
        content: '';
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: var(--muted-dim);
        flex-shrink: 0;
    }

    .nav-sub .nav-item.active::before {
        background: var(--brand);
    }

/* Scoped to the sidebar: .avatar is shared with tables, AccessDenied and the
   partner pages, which set their own sizes and must not shrink with the rail. */
.sidebar-foot .avatar {
    width: 26px;
    height: 26px;
    font-size: 10px;
}

.sidebar-foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    border-top: 1px solid var(--card-border);
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand-dim));
    color: var(--brand-contrast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.sidebar-foot .who {
    font-size: 11.5px;
    line-height: 1.3;
    white-space: nowrap;
}

    .sidebar-foot .who small {
        color: var(--muted);
        font-size: 10px;
    }

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 52px;
    padding: 0 20px;
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    background: var(--topbar-bg);
    backdrop-filter: blur(8px);
    z-index: 30;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

    .topbar .t-title h1 {
        font-size: 14px;
    }

    .topbar .t-title .sub {
        font-size: 11px;
        color: var(--muted);
        margin-top: 2px;
    }

.icon-btn {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    background: var(--bg-soft);
    border: 1px solid var(--card-border);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
    transition: color 0.18s, border-color 0.18s, background-color 0.3s ease;
}

    .icon-btn:hover {
        color: var(--brand);
        border-color: var(--brand-dim);
    }

    .icon-btn svg {
        width: 14px;
        height: 14px;
    }

    .icon-btn .dot {
        position: absolute;
        top: 5px;
        right: 6px;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--brand);
        box-shadow: 0 0 0 2px var(--bg-soft);
    }

.topbar .spacer {
    margin-left: auto;
}

.theme-btn .i-sun {
    display: none;
}

html.dark .theme-btn .i-moon {
    display: none;
}

html.dark .theme-btn .i-sun {
    display: block;
}

/* Topbar dropdowns */
/* The topbar dropdown menu (.dd / .dd-panel / .dd-item / .dd-user / .user-btn)
   was removed: MainLayout renders no dropdown at all — the topbar is a menu
   button, a title, a theme toggle and a sign-out link. app.js still delegates
   .dd clicks harmlessly, so re-adding the markup would light the styles back up
   if a dropdown is ever wanted; until then it was ~100 lines styling nothing. */

.content {
    padding: 24px 28px 48px;
}

/* ---------- Backdrop (mobile sidebar) ---------- */
.backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(12, 9, 7, 0.6);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.layout.sidebar-open .backdrop {
    opacity: 1;
    visibility: visible;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- Desktop: collapse to icon rail, hover to peek ---------- */
@media (min-width: 761px) {
    .backdrop {
        display: none;
    }

    .layout.collapsed .sidebar {
        width: 82px;
    }

        .layout.collapsed .sidebar .brand,
        .layout.collapsed .sidebar .nav-item,
        .layout.collapsed .sidebar .sidebar-foot {
            justify-content: center;
        }

        .layout.collapsed .sidebar .txt,
        .layout.collapsed .sidebar .badge-n,
        .layout.collapsed .sidebar .nav-arrow,
        .layout.collapsed .sidebar .who {
            display: none;
        }

        .layout.collapsed .sidebar .nav-sub {
            display: none;
        }

    .layout.collapsed .nav-label {
        text-align: center;
        padding: 0;
    }

        .layout.collapsed .nav-label .txt {
            display: none;
        }

        .layout.collapsed .nav-label .dots {
            display: block;
        }

    .layout.collapsed .sidebar:hover {
        width: var(--sidebar-w);
    }

        .layout.collapsed .sidebar:hover .brand,
        .layout.collapsed .sidebar:hover .nav-item,
        .layout.collapsed .sidebar:hover .sidebar-foot {
            justify-content: flex-start;
        }

        .layout.collapsed .sidebar:hover .txt {
            display: inline;
        }

        .layout.collapsed .sidebar:hover .badge-n {
            display: inline-block;
        }

        .layout.collapsed .sidebar:hover .nav-arrow {
            display: block;
        }

        .layout.collapsed .sidebar:hover .who {
            display: block;
        }

        .layout.collapsed .sidebar:hover .nav-group.open .nav-sub {
            display: block;
        }

        .layout.collapsed .sidebar:hover .nav-label {
            text-align: left;
            padding: 4px 8px 6px;
        }

            .layout.collapsed .sidebar:hover .nav-label .txt {
                display: inline;
            }

            .layout.collapsed .sidebar:hover .nav-label .dots {
                display: none;
            }

    /* Brand title: fade + slide instead of snapping (TailAdmin-style) */
    .layout.collapsed .sidebar .brand .txt {
        display: inline-block;
        max-width: 0;
        opacity: 0;
        margin-left: 0;
    }

    .layout.collapsed .sidebar:hover .brand .txt {
        max-width: 168px;
        opacity: 1;
        margin-left: 9px;
    }
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 40;
        width: var(--sidebar-w);
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .layout.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .content {
        padding: 18px 16px 44px;
    }

    .topbar {
        padding: 14px 16px;
    }

        .topbar .t-title .sub {
            display: none;
        }

    .dd-panel {
        width: 260px;
    }
}


