/* Shells: public site, auth, operator app. Grid helpers. */

.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding-left: var(--section-px);
    padding-right: var(--section-px);
}

.container.narrow {
    max-width: 820px;
}

.section {
    padding: var(--sp-12) 0;
}

@media (min-width: 768px) {
    .section {
        padding: var(--sp-16) 0;
    }
}

.section-raised {
    background: var(--bg-raised);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.section-lead {
    font-size: var(--fs-18);
    margin-bottom: var(--sp-8);
}

.page-head {
    padding-bottom: var(--sp-8);
}

/* Card grids: one column below 900 px, two between 900 and 1100, full width above (LQ-2). */
.grid-2,
.grid-3,
.grid-4 {
    display: grid;
    gap: var(--sp-6);
    grid-template-columns: 1fr;
}

@media (min-width: 900px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1100px) {
    .grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

.skip-link {
    position: absolute;
    left: -999px;
    top: var(--sp-2);
    background: var(--brand);
    color: var(--brand-ink);
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--radius-sm);
    z-index: 100;
}

.skip-link:focus {
    left: var(--sp-2);
}

/* public header */
.public-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(11, 13, 16, .92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.public-header-inner {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    min-height: 72px;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    color: var(--text);
    text-decoration: none;
}

.brand-link:hover {
    text-decoration: none;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-3);
}

.brand-logo {
    height: 40px;
    width: 83px;
}

.brand-word {
    font-weight: 600;
    font-size: var(--fs-20);
    letter-spacing: -0.01em;
    color: var(--text);
}

/* Disclosure menu below 900 px (LQ-1): the button toggles aria-expanded and .is-open on the header. */
.nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: 44px;
    min-width: 44px;
    padding: 0 var(--sp-3);
    margin-left: auto;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

.nav-toggle:hover {
    background: var(--bg-card);
}

.nav-toggle .nav-toggle-close,
.public-header.is-open .nav-toggle .nav-toggle-open {
    display: none;
}

.public-header.is-open .nav-toggle .nav-toggle-close {
    display: inline-block;
}

.public-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-card);
}

.public-header.is-open .public-nav {
    display: block;
}

.public-nav-list {
    list-style: none;
    margin: 0 auto;
    padding: var(--sp-2) var(--section-px) var(--sp-4);
    max-width: var(--container-max);
    display: grid;
}

.public-nav a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 var(--sp-2);
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.public-nav a:hover {
    color: var(--text);
    background: var(--bg-card);
    text-decoration: none;
}

.public-header-actions {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
}

.public-header-actions .btn-ghost {
    display: none;
}

@media (max-width: 479px) {
    .public-header-inner {
        gap: var(--sp-2);
    }

    /* The "Menu" word stays at 390 px (UX-19); only the padding tightens. */
    .nav-toggle {
        padding: 0 var(--sp-2);
        gap: var(--sp-1);
    }

    .public-header .brand-logo {
        height: 32px;
        width: 66px;
    }

    .public-header .brand-word {
        font-size: var(--fs-18);
    }

    .public-header-actions .btn-primary {
        min-height: 40px;
        padding: 0 var(--sp-3);
        font-size: var(--fs-14);
    }
}

@media (min-width: 900px) {
    .nav-toggle {
        display: none;
    }

    .public-nav,
    .public-header.is-open .public-nav {
        display: block;
        position: static;
        margin-left: var(--sp-6);
        background: transparent;
        border: 0;
        box-shadow: none;
    }

    .public-nav-list {
        display: flex;
        gap: var(--sp-2);
        padding: 0;
        max-width: none;
    }

    .public-nav a {
        min-height: 44px;
        padding: 0 var(--sp-3);
    }

    .public-nav-more {
        display: none;
    }

    .public-header-actions {
        margin-left: auto;
    }

}

/* Contact is in the desktop nav (UX-21); the ghost sign-in button joins once there is room for
   both (the footer and the 404 page carry Operator sign in below that). */
@media (min-width: 1180px) {
    .public-header-actions .btn-ghost {
        display: inline-flex;
    }
}

/* Public shell: footer sits at the bottom of short pages (404, contact). */
body.public {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.public-main {
    flex: 1 0 auto;
}

/* Breadcrumbs on nested public pages. */
.breadcrumbs {
    margin: 0 0 var(--sp-4);
    font-size: var(--fs-14);
}

.breadcrumbs ol {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    color: var(--text-muted);
}

.breadcrumbs li + li::before {
    content: "/";
    margin: 0 var(--sp-1);
    color: var(--border-strong);
}

.breadcrumbs a {
    color: var(--text-secondary);
}

.breadcrumbs [aria-current="page"] {
    color: var(--text);
}

/* public footer */
.public-footer {
    background: var(--bg-raised);
    border-top: 1px solid var(--border);
    padding: var(--sp-12) 0 var(--sp-6);
}

.public-footer-inner {
    display: grid;
    gap: var(--sp-8);
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .public-footer-inner {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .footer-brand {
        grid-column: 1 / -1;
    }
}

@media (min-width: 1024px) {
    .public-footer-inner {
        grid-template-columns: 2fr 1fr 1fr 1.4fr;
    }

    .footer-brand {
        grid-column: auto;
    }
}

.footer-brand p {
    margin-top: var(--sp-4);
}

.footer-made {
    color: var(--brand);
    font-weight: 500;
}

.footer-heading {
    font-size: var(--fs-14);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--sp-3);
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: var(--sp-2);
}

.footer-links a,
.footer-address a {
    color: var(--text-secondary);
}

.footer-address {
    display: grid;
    gap: var(--sp-2);
    color: var(--text-secondary);
}

.footer-address a {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
}

.footer-bottom {
    margin-top: var(--sp-8);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--border);
    font-size: var(--fs-14);
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2) var(--sp-6);
    justify-content: space-between;
}

.footer-family a {
    color: var(--text-secondary);
}

/* Paper: state checklists and legal pages print without chrome. */
@media print {
    body.public {
        background: #fff;
        color: #000;
        font-size: 12pt;
    }

    .skip-link,
    .public-header,
    .public-footer,
    .no-print {
        display: none !important;
    }

    .section {
        padding: 0 0 18pt;
    }

    .section-raised {
        background: transparent;
        border: 0;
    }

    h1,
    h2,
    h3,
    p,
    li,
    .lead,
    .text-secondary,
    .text-muted {
        color: #000;
    }

    a {
        color: #000;
        text-decoration: underline;
    }
}

/* auth shell */
.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--sp-6) var(--section-px);
}

.auth-header {
    padding: var(--sp-4) 0 var(--sp-8);
}

.auth-main {
    width: 100%;
    display: flex;
    justify-content: center;
    flex: 1;
}

.auth-footer {
    display: flex;
    gap: var(--sp-3);
    flex-wrap: wrap;
    justify-content: center;
    padding-top: var(--sp-8);
    font-size: var(--fs-14);
}

.auth-footer a {
    color: var(--text-secondary);
}

/* operator app shell: 18 px base, no sidebar, top bar only */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: var(--fs-18);
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    min-height: 64px;
    padding: 0 var(--section-px);
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
}

.app-brand:hover {
    text-decoration: none;
}

.app-brand-logo {
    height: 30px;
    width: auto;
}

.app-brand-word {
    font-weight: 600;
    font-size: var(--fs-18);
}

/* Top bar context (UX-4). Slots never truncate: below 1600 px the context takes its own row
   under the brand and the operator menu; below 1024 px the labels drop (values, icons and the
   scanner dot + state word stay); the full text is always in the slot's tooltip. */
.app-topbar {
    flex-wrap: wrap;
    row-gap: 0;
}

.app-context {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-2) var(--sp-6);
    margin-left: var(--sp-4);
    flex: 1 1 auto;
    min-width: 0;
}

.app-context-item {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    min-width: 0;
    font-size: var(--fs-16);
    white-space: nowrap;
    color: var(--text-secondary);
}

.app-context-item[hidden] {
    display: none;
}

.app-context-label {
    color: var(--text-muted);
}

.app-context-value {
    color: var(--text);
    font-weight: 500;
}

.scanner-pill {
    flex-shrink: 0;
    padding: 4px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--bg-inset);
}

.scanner-pill .scanner-word {
    display: none;
    color: var(--text);
    font-weight: 500;
}

.scanner-pill .scanner-full {
    color: var(--text);
    font-weight: 500;
}

.app-operator {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: var(--sp-2);
    min-width: 0;
}

.app-operator-name {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: 500;
    font-size: var(--fs-16);
    padding-right: var(--sp-2);
}

@media (max-width: 1599px) {
    .app-context {
        order: 3;
        flex-basis: 100%;
        margin: 0;
        padding: var(--sp-2) 0;
        border-top: 1px solid var(--border);
    }
}

@media (max-width: 1023px) {
    .app-context-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .app-context {
        gap: var(--sp-2) var(--sp-4);
    }

    .app-operator-name {
        display: none;
    }

    /* State word visible, full text kept for screen readers and in the tooltip. */
    .scanner-pill .scanner-word {
        display: inline;
    }

    .scanner-pill .scanner-full {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}

@media (max-width: 799px) {
    .app-operator .btn {
        padding: 0 var(--sp-2);
    }
}

.app-main {
    flex: 1;
    padding: var(--sp-6) var(--section-px) var(--sp-12);
}

.toast-region {
    position: fixed;
    bottom: var(--sp-6);
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    gap: var(--sp-2);
    z-index: 60;
}
