.app-navbar-brand {
    align-items: center;
    display: inline-flex;
    gap: 0.5rem;
    line-height: 1.2;
    max-width: calc(100vw - 5.5rem);
    white-space: normal;
}

.app-brand-logo {
    border-radius: 0.25rem;
    height: 2rem;
    object-fit: contain;
    width: 2rem;
}

.settings-logo-preview {
    max-height: 7rem;
    max-width: 12rem;
    object-fit: contain;
}

.print-only {
    display: none;
}

/* Bootstrap's .card only sets word-wrap: break-word, which is ignored when
   sizing flex items (e.g. the flex-wrap heading rows in order_detail.html),
   so a single long unbroken token (order reference, address, long name)
   still forces horizontal overflow on narrow viewports. overflow-wrap:
   anywhere is considered during flex min-content sizing and fixes that. */
.card {
    overflow-wrap: anywhere;
}

.compact-tables .table > :not(caption) > * > * {
    padding: 0.25rem 0.4rem;
}

/* Several order-lifecycle actions (add/remove order item, packing carton
   edits) intentionally redirect back to a same-page anchor further down
   order_detail.html (e.g. #order-items, #packing) so the operator lands
   next to what they just changed. Flash messages render above that
   anchor in the DOM, so the browser's fragment-scroll used to carry the
   success/error message out of view. Sticking the flash stack just below
   the topbar keeps it visible regardless of which anchor the page lands
   on. */
.app-flash-stack {
    position: sticky;
    top: 4.1rem;
    z-index: 1015;
}

.app-table-responsive {
    margin-bottom: 0;
}

.app-table-responsive > .table {
    margin-bottom: 0;
    min-width: max-content;
}

.app-table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-width: 9rem;
}

.app-table-actions > form {
    margin: 0;
}

.app-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.report-summary-card {
    border-left: 0.25rem solid var(--bs-success);
}

.report-filter-context {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

.report-filter-actions {
    flex-wrap: wrap;
}

@media (max-width: 575.98px) {
    .app-navbar-brand {
        font-size: 0.95rem;
    }

    .app-table-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .app-table-actions > button,
    .app-table-actions > form,
    .app-table-actions > form > button {
        width: 100%;
    }

    .report-filter-actions > .btn {
        flex: 1 1 auto;
    }
}

/* ===== Application shell ===== */
:root {
    --gwms-primary: #138a60;
    --gwms-primary-dark: #0b6d4a;
    --gwms-primary-soft: #eaf8f2;
    --gwms-bg: #f4f7f6;
    --gwms-surface: #ffffff;
    --gwms-text: #17231f;
    --gwms-muted: #66746f;
    --gwms-border: #dfe8e4;
    --gwms-warning-soft: #fff8ec;
    --gwms-warning-border: #f1c98a;
    --gwms-radius: 0.85rem;
    --gwms-sidebar-width: 15.5rem;
}

.app-body {
    background: var(--gwms-bg);
    color: var(--gwms-text);
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    background: #0d6f4c;
    bottom: 0;
    color: #fff;
    display: flex;
    flex-direction: column;
    left: 0;
    overflow: hidden;
    padding: 1.25rem 1rem;
    position: fixed;
    top: 0;
    width: var(--gwms-sidebar-width);
    z-index: 1040;
}

.app-sidebar-brand {
    align-items: center;
    color: #fff;
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0.35rem 0.5rem;
    text-decoration: none;
}

.app-sidebar-brand:hover { color: #fff; }
.app-sidebar-brand strong { display: block; font-size: 1.05rem; }
.app-sidebar-brand small { color: rgba(255,255,255,.68); display: block; font-size: .74rem; }

.app-brand-mark {
    align-items: center;
    background: rgba(255,255,255,.17);
    border: 1px solid rgba(255,255,255,.24);
    border-radius: .65rem;
    display: inline-flex;
    font-size: 1.1rem;
    font-weight: 800;
    height: 2.35rem;
    justify-content: center;
    width: 2.35rem;
}

.app-sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
}
.app-nav-label {
    color: rgba(255,255,255,.52);
    font-size: .67rem;
    font-weight: 700;
    letter-spacing: .08em;
    margin: 1.15rem .75rem .45rem;
    text-transform: uppercase;
}

.app-nav-link {
    align-items: center;
    border-radius: .65rem;
    color: rgba(255,255,255,.86);
    display: flex;
    font-size: .96rem;
    font-weight: 550;
    gap: .7rem;
    min-height: 2.65rem;
    padding: .65rem .7rem;
    text-decoration: none;
}

.app-nav-link:hover,
.app-nav-link.active {
    background: rgba(255,255,255,.13);
    color: #fff;
}

.app-nav-link.active { font-weight: 650; }
.app-nav-link-muted {
    color: rgba(255,255,255,.58);
    font-size: .85rem;
    min-height: 2.3rem;
}
.app-nav-link-muted:hover,
.app-nav-link-muted.active {
    color: rgba(255,255,255,.92);
}
.app-nav-icon {
    align-items: center;
    background: rgba(255,255,255,.12);
    border-radius: .45rem;
    display: inline-flex;
    flex: 0 0 1.9rem;
    font-size: .66rem;
    font-weight: 800;
    height: 1.9rem;
    justify-content: center;
    letter-spacing: .02em;
    width: 1.9rem;
}

.app-sidebar-user {
    align-items: center;
    border-top: 1px solid rgba(255,255,255,.16);
    display: flex;
    flex: 0 0 auto;
    justify-content: space-between;
    margin-top: 1rem;
    padding: 1rem .5rem 0;
}

.app-sidebar-user strong,
.app-sidebar-user small { display: block; }
.app-sidebar-user small { color: rgba(255,255,255,.6); font-size: .72rem; }
.app-sidebar-user form { margin: 0; }
.app-logout-button {
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.22);
    border-radius: .55rem;
    color: #fff;
    cursor: pointer;
    font-size: .88rem;
    font-weight: 700;
    padding: .5rem .75rem;
}

.app-main { margin-left: var(--gwms-sidebar-width); min-height: 100vh; }
.app-topbar {
    align-items: center;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--gwms-border);
    display: flex;
    height: 4.1rem;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-menu-button {
    background: transparent;
    border: 0;
    color: var(--gwms-text);
    display: none;
    font-size: 1.25rem;
}

.app-mobile-brand { color: var(--gwms-text); display: none; font-weight: 700; text-decoration: none; }
.app-topbar-user { align-items: center; display: flex; font-size: .88rem; gap: .55rem; margin-left: auto; }
.app-user-avatar {
    align-items: center;
    background: var(--gwms-primary-soft);
    border-radius: 50%;
    color: var(--gwms-primary-dark);
    display: inline-flex;
    font-weight: 700;
    height: 2rem;
    justify-content: center;
    width: 2rem;
}

.app-content { margin: 0 auto; max-width: 92rem; overflow-wrap: anywhere; padding: 1.75rem; }
.app-sidebar-backdrop { display: none; }

/* ===== Dashboard ===== */
.dashboard-page { display: grid; gap: 1.25rem; padding-bottom: calc(4.75rem + env(safe-area-inset-bottom)); }
.dashboard-heading { align-items: flex-end; display: flex; justify-content: space-between; }
.dashboard-heading h1 { font-size: 2rem; font-weight: 780; line-height: 1.15; margin: 0; }
.dashboard-heading p { color: var(--gwms-muted); margin: .35rem 0 0; }
.dashboard-heading-title { align-items: center; display: flex; gap: .6rem; }
.dashboard-heading-logo { border-radius: .3rem; height: 2rem; object-fit: contain; width: 2rem; }
.dashboard-card-title { color: var(--gwms-primary-dark); }
.dashboard-eyebrow { color: var(--gwms-primary) !important; font-size: .72rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.dashboard-date { text-align: right; }
.dashboard-date span { color: var(--gwms-muted); display: block; font-size: .72rem; }
.dashboard-date strong { font-size: .94rem; }

.dashboard-summary-card,
.dashboard-panel {
    background: var(--gwms-surface);
    border: 1px solid var(--gwms-border);
    border-radius: var(--gwms-radius);
    box-shadow: 0 6px 18px rgba(19, 59, 43, .04);
}

.dashboard-summary-card { overflow: hidden; }
.dashboard-summary-card summary {
    align-items: center;
    cursor: pointer;
    display: flex;
    gap: .85rem;
    list-style: none;
    padding: 1.05rem 1.2rem;
}
.dashboard-summary-card summary::-webkit-details-marker { display: none; }
.dashboard-summary-card summary > span:nth-child(2) { flex: 1; }
.dashboard-summary-card summary strong { display: block; font-size: .98rem; }
.dashboard-summary-card summary small { color: var(--gwms-muted); display: block; font-size: .78rem; margin-top: .12rem; }
.dashboard-summary-icon,
.dashboard-link-icon {
    align-items: center;
    background: var(--gwms-primary-soft);
    border-radius: .6rem;
    color: var(--gwms-primary-dark);
    display: inline-flex;
    height: 2.35rem;
    justify-content: center;
    width: 2.35rem;
}
.dashboard-chevron { color: var(--gwms-muted); font-size: 1.15rem; transition: transform .15s ease; }
.dashboard-summary-card[open] .dashboard-chevron { transform: rotate(180deg); }
.dashboard-summary-content { border-top: 1px solid var(--gwms-border); max-height: 28rem; overflow: auto; }
.dashboard-table thead th { background: #f3f8f6; border-bottom: 1px solid var(--gwms-border); color: #4f625b; font-size: .72rem; letter-spacing: .02em; white-space: nowrap; }
.dashboard-table td { border-color: #edf2f0; font-size: .84rem; white-space: nowrap; }

.dashboard-link-grid,
.dashboard-detail-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard-link-card {
    align-items: center;
    background: var(--gwms-surface);
    border: 1px solid var(--gwms-border);
    border-left: .28rem solid #7c66d9;
    border-radius: var(--gwms-radius);
    color: var(--gwms-text);
    display: flex;
    gap: .85rem;
    padding: 1rem 1.1rem;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}
.dashboard-link-card:hover { box-shadow: 0 9px 22px rgba(19, 59, 43, .08); color: var(--gwms-text); transform: translateY(-1px); }
.dashboard-link-card strong { display: block; font-size: 1.05rem; line-height: 1.3; }
.dashboard-link-card small { color: var(--gwms-muted); display: block; font-size: .86rem; line-height: 1.45; margin-top: .2rem; }
.dashboard-link-card > span:nth-child(2) { flex: 1; }
.dashboard-link-arrow { color: var(--gwms-muted); }
.dashboard-link-blue { border-left-color: #4285d4; }
.dashboard-link-blue .dashboard-link-icon { background: #eef5ff; color: #285f9f; }
.dashboard-link-purple .dashboard-link-icon { background: #f3efff; color: #6b56bd; }

.dashboard-panel { overflow: hidden; }
.dashboard-panel-warning { border-color: var(--gwms-warning-border); }
.dashboard-panel-header {
    align-items: center;
    border-bottom: 1px solid var(--gwms-border);
    display: flex;
    justify-content: space-between;
    padding: .9rem 1rem;
}
.dashboard-panel-header > div { align-items: center; display: flex; gap: .5rem; }
.dashboard-panel-header h2 { font-size: .94rem; font-weight: 700; margin: 0; }
.dashboard-panel-header a { color: var(--gwms-primary-dark); font-size: .75rem; font-weight: 650; text-decoration: none; }
.panel-dot { border-radius: 50%; height: .55rem; width: .55rem; }
.panel-dot-green { background: var(--gwms-primary); }
.panel-dot-orange { background: #e89b2d; }

.dashboard-mini-head,
.dashboard-mini-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; }
.dashboard-mini-head { background: #f7faf9; color: var(--gwms-muted); font-size: .69rem; font-weight: 700; letter-spacing: .03em; padding: .58rem 1rem; text-transform: uppercase; }
.dashboard-mini-row { align-items: center; border-top: 1px solid #edf2f0; font-size: .85rem; padding: .78rem 1rem; }
.dashboard-mini-row:first-of-type { border-top: 0; }
.dashboard-mini-row strong { font-size: .83rem; white-space: nowrap; }
.dashboard-empty { color: var(--gwms-muted); font-size: .84rem; padding: 1.35rem; text-align: center; }
.dashboard-empty-success { color: var(--gwms-primary-dark); }

.dashboard-actions-section {
    background: var(--gwms-surface);
    border-top: 1px solid var(--gwms-border);
    bottom: 0;
    box-shadow: 0 -6px 18px rgba(19, 59, 43, .06);
    left: var(--gwms-sidebar-width);
    padding: .5rem 1.75rem calc(.5rem + env(safe-area-inset-bottom));
    position: fixed;
    right: 0;
    z-index: 1010;
}
.dashboard-actions-grid { display: grid; gap: .5rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-actions-grid a {
    align-items: center;
    background: #f8fbfa;
    border: 1px solid var(--gwms-border);
    border-radius: .7rem;
    color: var(--gwms-text);
    display: flex;
    gap: .6rem;
    justify-content: center;
    padding: .85rem;
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease;
}
.dashboard-actions-grid a:hover { background: var(--gwms-primary-soft); border-color: #add9c7; }
.dashboard-actions-grid span { color: var(--gwms-primary-dark); }
.dashboard-actions-grid strong { font-size: .84rem; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .app-main { margin-left: 0; }
    .app-menu-button, .app-mobile-brand { display: inline-block; }
    .app-topbar { padding: 0 1rem; }
    .app-menu-button { margin-right: .75rem; }
    .app-mobile-brand { margin-right: auto; }
    .sidebar-open .app-sidebar { transform: translateX(0); }
    .sidebar-open .app-sidebar-backdrop { background: rgba(0,0,0,.35); display: block; inset: 0; position: fixed; z-index: 1030; }
    .dashboard-actions-section { left: 0; }
}

@media (max-width: 767.98px) {
    .app-content { padding: 1rem; }
    .dashboard-heading { align-items: flex-start; flex-direction: column; gap: .75rem; }
    .dashboard-date { text-align: left; }
    .dashboard-link-grid,
    .dashboard-detail-grid { grid-template-columns: 1fr; }
    .dashboard-summary-card summary { padding: .9rem; }
    .dashboard-heading-logo { height: 1.625rem; width: 1.625rem; }
    .dashboard-actions-section { padding: .4rem .5rem calc(.4rem + env(safe-area-inset-bottom)); }
    .dashboard-actions-grid { gap: .35rem; }
    .dashboard-actions-grid a { flex-direction: column; gap: .2rem; padding: .4rem .1rem; }
    .dashboard-actions-grid span { font-size: .9rem; }
    .dashboard-actions-grid strong { font-size: .64rem; white-space: nowrap; }
    .dashboard-page { padding-bottom: calc(5.75rem + env(safe-area-inset-bottom)); }
}

@media print {
    .app-main { margin-left: 0; }
    .app-content { max-width: none; padding: 0; }
    .dashboard-page { padding-bottom: 0; }
}


/* Authentication */
.auth-page {
    min-height: calc(100vh - 3rem);
    display: grid;
    place-items: center;
    padding: 1.5rem;
}
.auth-card {
    width: min(100%, 430px);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}
.auth-brand { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.5rem; }
.auth-logo { width: 64px; height: 64px; object-fit: contain; }
.auth-business-name { margin: 0 0 .25rem; color: #15803d; font-weight: 700; }
.auth-brand h1 { margin: 0; font-size: 1.75rem; }
.auth-brand p:last-child { margin: .35rem 0 0; color: #64748b; }
.auth-form { display: grid; gap: 1rem; }

.app-menu-bars {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
    width: 18px;
}

.app-menu-bars > span {
    background: currentColor;
    border-radius: 999px;
    display: block;
    height: 2px;
    width: 100%;
}

/* Report type tabs (Phase 2A: keeps all report routes reachable from one entry point) */
.report-type-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}
.report-type-tab {
    background: var(--gwms-surface);
    border: 1px solid var(--gwms-border);
    border-radius: 999px;
    color: var(--gwms-text);
    font-size: .85rem;
    font-weight: 600;
    padding: .4rem .9rem;
    text-decoration: none;
    white-space: nowrap;
}
.report-type-tab:hover {
    background: var(--gwms-primary-soft);
}
.report-type-tab.active {
    background: var(--gwms-primary);
    border-color: var(--gwms-primary);
    color: #fff;
}
@media (max-width: 575.98px) {
    .report-type-tabs { gap: .4rem; }
    .report-type-tab { font-size: .8rem; padding: .35rem .7rem; }
}
