/* ---------------------------------------------------------------------------
   ClientSpace shell: primary navigation, sub-navigation, content.

   >= 1040px   primary menu (icons + labels) | sub-navigation menu | content
   770-1039    top bar with a menu button (the primary menu opens full screen) | sub-navigation menu | content
   < 770       top bar with a menu button | sub-navigation as a scrolling top menu | content

   Colours come from the firm's settings through --navy and --red (set in the layout), so the
   same shell wears each firm's branding. Builds on style.css (buttons, fields, tables, dialogs).
   --------------------------------------------------------------------------- */

:root {
    --navy-tint:        color-mix(in srgb, var(--navy) 7%, #fff);
    --navy-tint-strong: color-mix(in srgb, var(--navy) 13%, #fff);
    --nav-w:            15rem;
    --nav-w-collapsed:  4.5rem;
    --sub-w:            19rem;
    --topbar-h:         3.75rem;
}

body.app { background: #fff; }

.skip {
    position: absolute; left: -999px; top: 0; z-index: 100;
    background: var(--navy); color: #fff; padding: 0.5rem 1rem; border-radius: 0 0 3px 0;
}
.skip:focus { left: 0; }

.icon { width: 1.25rem; height: 1.25rem; flex: none; }

.iconbutton {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.25rem; height: 2.25rem; padding: 0; border: 0; border-radius: 0.5rem;
    background: transparent; color: var(--ink-soft); cursor: pointer;
}
.iconbutton:hover { background: var(--paper-sunk); color: var(--navy); }
.iconbutton:focus-visible, .navitem:focus-visible, .subnav__item:focus-visible, .topbar__menu:focus-visible, .secondary__action:focus-visible {
    outline: 2px solid var(--navy); outline-offset: 2px;
}

/* ---- Top bar: only below 1040px ------------------------------------------ */

.topbar { display: none; }

/* ---- The three columns ---------------------------------------------------- */

.shell {
    display: grid;
    grid-template-columns: var(--nav-w) var(--sub-w) minmax(0, 1fr);
    min-height: 100vh;
}
.shell--nosub { grid-template-columns: var(--nav-w) minmax(0, 1fr); }
body.is-collapsed { --nav-w: var(--nav-w-collapsed); }

/* ---- Primary navigation --------------------------------------------------- */

.primary {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
    background: #fff; border-right: 1px solid var(--rule);
    overflow-x: hidden; overflow-y: auto;
}
.primary__head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 1.125rem 0.75rem 0.5rem 1.25rem; min-height: 5.25rem; }
.primary__logo { display: block; line-height: 0; }
.primary__logo img { display: block; width: 8.75rem; height: auto; }
.primary__close { display: none; }

.primary__list, .primary__foot { list-style: none; margin: 0; padding: 0.5rem 0.75rem; }
.primary__list { flex: 1 1 auto; }
.primary__foot { border-top: 1px solid var(--rule); padding-bottom: 1rem; }
.primary li { margin: 0 0 0.125rem; }

.navitem {
    display: flex; align-items: center; gap: 0.75rem; width: 100%;
    padding: 0.625rem 0.75rem; border: 0; border-radius: 0.5rem;
    background: transparent; color: var(--ink); text-decoration: none;
    font: inherit; font-size: 0.9375rem; line-height: 1.3; text-align: left; cursor: pointer;
}
.navitem span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navitem:hover { background: var(--paper-sunk); }
.navitem.is-active { background: var(--navy-tint-strong); color: var(--navy); font-weight: 600; }
.navitem--user { cursor: default; color: var(--ink-soft); font-size: 0.8125rem; }
.navitem--user:hover { background: transparent; }
.primary form { margin: 0; }

/* Collapsed to icons only (the button is for wide screens; the choice is remembered) */
body.is-collapsed .primary__logo,
body.is-collapsed .navitem span { display: none; }
body.is-collapsed .primary__head { justify-content: center; padding-left: 0.75rem; }
body.is-collapsed .navitem { justify-content: center; padding-left: 0; padding-right: 0; }

/* ---- Sub-navigation ------------------------------------------------------- */

.secondary {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
    background: #fff; border-right: 1px solid var(--rule); overflow: hidden;
}
.secondary__head {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
    padding: 1.25rem 1.25rem 0.875rem; min-height: 5.25rem;
}
.secondary .secondary__title {
    margin: 0; padding: 0; border: 0;
    font-size: 1.375rem; font-weight: 600; line-height: 1.2; color: var(--ink);
}
.secondary__action {
    display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.4375rem 0.75rem;
    border: 1px solid var(--rule); border-radius: 0.5rem; background: #fff;
    color: var(--navy); font-size: 0.8125rem; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.secondary__action:hover { background: var(--navy-tint); }
.secondary__action .icon { width: 1rem; height: 1rem; }

.secondary__filter { padding: 0 1rem 0.75rem; }
.secondary__filter input {
    width: 100%; font: inherit; font-size: 0.875rem; padding: 0.5rem 0.75rem;
    border: 1px solid #c3c3cf; border-radius: 0.5rem; background: #fff;
}
.secondary__filter input:focus-visible { outline: 2px solid var(--navy); outline-offset: 1px; }
.secondary__nav { flex: 1 1 auto; overflow-y: auto; border-top: 1px solid var(--rule); }

.subnav { list-style: none; margin: 0; padding: 0; position: relative; }
.subnav li { margin: 0; }
.subnav li[hidden] { display: none; }
.subnav__item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.875rem 1.25rem; border-bottom: 1px solid var(--rule);
    border-left: 3px solid transparent;
    color: var(--ink); text-decoration: none; font-size: 0.9375rem; line-height: 1.3;
}
.subnav__item:hover { background: var(--paper-sunk); }
.subnav__item.is-active { background: var(--navy-tint-strong); border-left-color: var(--navy); color: var(--navy); }
.subnav__item.is-active .subnav__label { font-weight: 600; }
.subnav__item.is-active .avatar { background: #fff; }
.subnav__text { display: flex; flex-direction: column; min-width: 0; }
.subnav__label { overflow: hidden; text-overflow: ellipsis; }
.subnav__sub { font-size: 0.75rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
    flex: none; display: inline-flex; align-items: center; justify-content: center;
    width: 2.25rem; height: 2.25rem; border-radius: 50%;
    background: var(--navy-tint-strong); color: var(--navy); font-size: 0.75rem; font-weight: 600;
}
/* Questionnaire sections: a status mark instead of an avatar */
.subnav__mark { flex: none; display: inline-flex; width: 1.25rem; height: 1.25rem; color: var(--ink-soft); }
.subnav__mark svg { width: 100%; height: 100%; }
.subnav__mark.is-complete { color: var(--green); }
.subnav__mark.is-progress { color: var(--navy); }

/* ---- Content -------------------------------------------------------------- */

.content { min-width: 0; display: flex; flex-direction: column; }
.content__inner { flex: 1 0 auto; width: 100%; max-width: 62rem; padding: 2.25rem 2.5rem 3rem; }
.colophon--app { max-width: none; width: 100%; margin: 0; padding: 1.25rem 2.5rem 2rem; }

.content__inner > h1:first-child { margin-top: 0; }
.content .queue td, .content .queue th { padding-right: 1rem; }

/* ---- Below 1040px: the primary menu moves behind the top bar's button ------ */

@media (max-width: 1039px) {
    :root { --sub-w: 16.25rem; }

    .topbar {
        display: flex; position: sticky; top: 0; z-index: 40;
        align-items: center; justify-content: space-between;
        height: var(--topbar-h); padding: 0 0.75rem 0 1.25rem;
        background: #fff; border-bottom: 1px solid var(--rule);
        /* the firm mark's thin red keyline, as on the old masthead */
        box-shadow: inset 0 -4px 0 -3px var(--red);
    }
    .topbar__logo { display: block; line-height: 0; }
    .topbar__logo img { display: block; height: 2.75rem; width: auto; }
    .topbar__menu {
        display: inline-flex; align-items: center; justify-content: center;
        width: 2.75rem; height: 2.75rem; border: 0; border-radius: 0.5rem;
        background: transparent; color: var(--ink); cursor: pointer;
    }
    .topbar__menu:hover { background: var(--paper-sunk); }
    .topbar__menu .icon { width: 1.5rem; height: 1.5rem; }

    .shell { grid-template-columns: var(--sub-w) minmax(0, 1fr); }
    .shell--nosub { grid-template-columns: minmax(0, 1fr); }

    /* The menu opens as a full-screen sheet */
    .primary {
        position: fixed; inset: 0; z-index: 60; height: auto; width: auto;
        display: none; border-right: 0;
    }
    body.nav-open { overflow: hidden; }
    body.nav-open .primary { display: flex; }
    .primary__head { justify-content: flex-end; min-height: var(--topbar-h); padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--rule); }
    .primary__logo, .primary__collapse { display: none; }
    .primary__close { display: inline-flex; width: 2.75rem; height: 2.75rem; }
    .primary__close .icon { width: 1.5rem; height: 1.5rem; }
    .primary__list { padding: 0; }
    .primary__list li, .primary__foot li { margin: 0; }
    .primary__foot { padding: 0 0 1rem; }
    .navitem { border-radius: 0; padding: 0.9375rem 1.25rem; font-size: 1rem; }
    .navitem--user { font-size: 0.9375rem; }
    body.is-collapsed .navitem span { display: inline; }      /* the collapsed setting never applies to the full-screen menu */
    body.is-collapsed .navitem { justify-content: flex-start; padding: 0.9375rem 1.25rem; }

    .secondary { top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); }
    .content__inner { padding: 2rem 1.75rem 2.5rem; }
    .colophon--app { padding: 1.25rem 1.75rem 2rem; }
}

/* ---- Below 770px: the sub-navigation becomes a top menu -------------------- */

@media (max-width: 769px) {
    .shell, .shell--nosub { grid-template-columns: minmax(0, 1fr); }

    .secondary {
        position: sticky; top: var(--topbar-h); z-index: 30; min-width: 0; max-width: 100%;
        height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
        border-right: 0; border-bottom: 1px solid var(--rule); overflow: visible;
    }
    .secondary__head { flex: 1 1 100%; min-height: 0; padding: 0.625rem 1rem 0.25rem; }
    .secondary .secondary__title { font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); }
    .secondary__filter { display: none; }
    .secondary__nav { flex: 1 1 100%; min-width: 0; max-width: 100%; border-top: 0; overflow: hidden; }
    .subnav { display: flex; gap: 0.5rem; padding: 0.25rem 1rem 0.75rem; overflow-x: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
    .subnav li { flex: none; }
    .subnav__item {
        padding: 0.4375rem 0.875rem; border: 1px solid var(--rule); border-radius: 999px;
        background: #fff; font-size: 0.875rem; white-space: nowrap;
    }
    .subnav__item.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
    .subnav__item.is-active .subnav__mark { color: #fff; }
    .subnav .avatar { display: none; }
    .subnav__sub { display: none; }
    .subnav__label { overflow: visible; }

    .content__inner { padding: 1.5rem 1.25rem 2.25rem; }
    .colophon--app { padding: 1rem 1.25rem 2rem; }
    .content .queue { display: block; overflow-x: auto; }
}

/* ---- Pages that live inside the shell ------------------------------------- */

.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem; margin: 0 0 2rem; }
.stat { border: 1px solid var(--rule); border-radius: 0.5rem; padding: 1rem 1.125rem; background: #fff; }
.stat__n { display: block; font-size: 1.875rem; font-weight: 600; line-height: 1.1; color: var(--navy); }
.stat__label { font-size: 0.8125rem; color: var(--ink-soft); }

.cardlist { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.cardlist > li { margin: 0 0 0.625rem; }
.rowcard {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem;
    border: 1px solid var(--rule); border-radius: 0.5rem; padding: 0.875rem 1.125rem; background: #fff;
}
.rowcard__main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 14rem; }
.rowcard__title { font-weight: 600; color: var(--ink); }
.rowcard__sub { font-size: 0.8125rem; color: var(--ink-soft); }
.rowcard__bar { margin-top: 0.5rem; height: 4px; background: var(--rule); border-radius: 2px; overflow: hidden; }
.rowcard__bar > span { display: block; height: 100%; background: var(--navy); }

.contactgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; margin: 0 0 1.5rem; }
.contactcard { display: flex; gap: 0.875rem; align-items: flex-start; border: 1px solid var(--rule); border-radius: 0.5rem; padding: 1rem 1.125rem; }
.contactcard .icon { color: var(--navy); margin-top: 0.125rem; }
.contactcard strong { display: block; }
.contactcard a { word-break: break-word; }
.detailgrid { display: grid; grid-template-columns: max-content 1fr; gap: 0.375rem 1.5rem; margin: 0 0 1.5rem; font-size: 0.9375rem; }
.detailgrid dt { color: var(--ink-soft); }
.detailgrid dd { margin: 0; }

@media print {
    .topbar, .primary, .secondary, .skip, .colophon--app { display: none !important; }
    .shell { display: block; }
}

/* Forms inside the shell */
.checkrow { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.375rem; font-weight: 400; }
.checkrow input { margin: 0; }
.formgrid { max-width: 30rem; }
.formgrid select, .formgrid input[type="text"] { width: 100%; }
.rowcard__actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.rowcard__actions form { margin: 0; }
.linkbutton--danger { color: var(--red); }
