/* ============================================================================
   Park Industries® Portals — Shared Design System
   Consumed by BOTH the external customer portal and the internal associates portal.
   ----------------------------------------------------------------------------
   Component library that mirrors the look & feel of the CX Platform demo
   (customer-hub / internal-hub / pricing-tool / tech-dispatch) while staying
   on-brand per the PI Brand Style & Visual Guide.

   Loaded AFTER app.css, so it extends and refines the existing brand base:
     • Brand palette is unchanged (Midnight #04173F, Scarlet #FF2400,
       Steel Blue #5494CC, Forged Pewter #A9A392).
     • Typography stays Figtree + Arial; headings remain uppercase.
   What this file adds, taken from the demo's shared language:
     • Soft rounded cards + soft shadows
     • KPI / stat cards with colored top accents
     • Status pills with tinted backgrounds
     • Section headers, card headers, badges, alerts, empty states
     • Dark-header "machine" cards
     • Layout grid helpers and a subtle PI dot pattern utility
   These are additive component classes; page layout is not restructured.
   ========================================================================== */

:root {
    /* Semantic colors + tinted backgrounds (from the demo palettes) */
    --pi-green:        #1b7a3d;
    --pi-green-tint:   #e8f5e8;
    --pi-amber:        #b85c00;
    --pi-amber-tint:   #fff3e0;
    --pi-info:         #0d47a1;
    --pi-info-tint:    #e3f2fd;
    --pi-scarlet-tint: #fff0ed;
    --pi-steel-tint:   #e9f2fb;

    /* Surfaces / depth */
    --ds-radius:    10px;
    --ds-radius-sm: 7px;
    --ds-shadow:    0 2px 10px rgba(4, 23, 63, 0.08);
    --ds-shadow-lg: 0 8px 24px rgba(4, 23, 63, 0.14);

    /* Muted text that reads softer than --pi-ink for secondary copy */
    --ds-muted: #6b7280;
}

/* ----------------------------------------------------------------------------
   Card refinement — soften the existing brand cards to the demo aesthetic
   (rounded corners + soft shadow + scarlet hover accent), keeping the
   midnight top rule that gives PI cards their identity.
---------------------------------------------------------------------------- */
.card {
    border-radius: var(--ds-radius);
    box-shadow: var(--ds-shadow);
}

.card-link:hover {
    box-shadow: var(--ds-shadow-lg);
}

/* A plain surface card with no top rule, for dashboard widgets. */
.ds-card {
    background: var(--pi-white);
    border: 1px solid var(--pi-border);
    border-radius: var(--ds-radius);
    box-shadow: var(--ds-shadow);
    padding: 20px;
    margin-bottom: 20px;
}

/* Opt-in modifier: gives a .ds-card the midnight top rule that identifies a PI content
   card, matching `.card` in app.css. Use it when a .ds-card is a page's main content
   surface rather than a dashboard widget — the plain .ds-card stays rule-less. */
.ds-card-ruled { border-top: 4px solid var(--pi-midnight); }

/* Small uppercase label that heads a card's content (demo `.card-hdr`). */
.card-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--ds-muted);
}

/* ----------------------------------------------------------------------------
   Section header — page/section title with optional sub-line and right action
---------------------------------------------------------------------------- */
.section-hdr {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.section-hdr h2 {
    margin: 0;
    font-size: 1.25rem;
    letter-spacing: 1px;
}

.section-hdr .sub {
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--ds-muted);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 600;
}

/* ----------------------------------------------------------------------------
   KPI / stat cards — colored top accent, icon tile, big value, label
---------------------------------------------------------------------------- */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}

.kpi {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--pi-white);
    border: 1px solid var(--pi-border);
    border-top: 3px solid var(--pi-pewter);
    border-radius: var(--ds-radius);
    box-shadow: var(--ds-shadow);
    padding: 18px 20px;
}

.kpi.scarlet { border-top-color: var(--pi-scarlet); }
.kpi.navy    { border-top-color: var(--pi-midnight); }
.kpi.green   { border-top-color: var(--pi-green); }
.kpi.amber   { border-top-color: var(--pi-amber); }
.kpi.steel   { border-top-color: var(--pi-steel); }

/* Clickable KPI tiles (rendered as <a class="kpi kpi-link">) — same look as a
   static tile, plus the lift/shadow hover affordance used by .card-link. */
.kpi-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.kpi-link:hover,
.kpi-link:focus-visible {
    transform: translateY(-2px);
    box-shadow: var(--ds-shadow-lg);
}

.kpi-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ds-radius-sm);
    font-size: 20px;
}

.kpi.scarlet .kpi-icon { background: var(--pi-scarlet-tint); color: var(--pi-scarlet); }
.kpi.navy    .kpi-icon { background: var(--pi-steel-tint);   color: var(--pi-midnight); }
.kpi.green   .kpi-icon { background: var(--pi-green-tint);   color: var(--pi-green); }
.kpi.amber   .kpi-icon { background: var(--pi-amber-tint);   color: var(--pi-amber); }
.kpi.steel   .kpi-icon { background: var(--pi-steel-tint);   color: var(--pi-steel); }

.kpi-val {
    font-size: 1.7rem;
    font-weight: 900;
    line-height: 1;
    color: var(--pi-midnight);
}

.kpi-lbl {
    margin-top: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: var(--ds-muted);
    text-transform: uppercase;
}

/* ----------------------------------------------------------------------------
   Layout grid helpers (from the demo's dashboard grids)
---------------------------------------------------------------------------- */
.grid-2     { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
.grid-2-eq  { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3     { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ----------------------------------------------------------------------------
   Status pills — tinted background + colored text (demo `.pill`)
   Also restyles the existing solid `.status` chips into the softer pill look.
---------------------------------------------------------------------------- */
.pill,
.status {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    white-space: nowrap;
    line-height: 1.6;
}

/* Generic pill variants */
.pill-scarlet { background: var(--pi-scarlet-tint); color: var(--pi-scarlet); }
.pill-navy    { background: var(--pi-steel-tint);   color: var(--pi-midnight); }
.pill-steel   { background: var(--pi-steel-tint);   color: var(--pi-steel); }
.pill-green   { background: var(--pi-green-tint);   color: var(--pi-green); }
.pill-amber   { background: var(--pi-amber-tint);   color: var(--pi-amber); }
.pill-info    { background: var(--pi-info-tint);    color: var(--pi-info); }
.pill-muted   { background: #eef0f2;               color: var(--ds-muted); }

/* Service work-order status pills, from the service owner's status reference. These hexes
   are the spec's own and deliberately don't reuse the generic pill colors above. The
   code -> pill mapping is WorkOrderStates.PillFor in Portal.Data, shared by both portals. */
.wo-status-gray { background: rgba(90,90,90,0.12);  color: #5A5A5A; white-space: nowrap; }
.wo-status-blue { background: rgba(13,71,161,0.10); color: #0D47A1; white-space: nowrap; }
.wo-status-navy { background: rgba(4,23,63,0.10);   color: #04173F; white-space: nowrap; }
.wo-status-amber { background: rgba(184,64,0,0.12);  color: #B84000; white-space: nowrap; }
.wo-status-sky   { background: rgba(2,132,199,0.12); color: #0284C7; white-space: nowrap; }
.wo-status-teal  { background: rgba(15,122,115,0.12); color: #0F7A73; white-space: nowrap; }
.wo-status-green { background: rgba(27,107,27,0.12); color: #1B6B1B; white-space: nowrap; }
/* Canceled: the spec's #FF2400 is the tint; the text is darkened to #C21C00 for contrast, the
   same pairing Order History uses for its red. */
.wo-status-red   { background: rgba(255,36,0,0.12);  color: #C21C00; white-space: nowrap; }

/* Map the portal's existing status classes onto the tinted pill look.
   (These override the solid backgrounds defined in app.css.) */
.status            { background: #eef0f2; color: var(--ds-muted); }
.status-submitted  { background: #eef0f2;               color: var(--ds-muted); }
.status-inreview   { background: var(--pi-steel-tint);  color: var(--pi-steel); }
.status-scheduled  { background: var(--pi-steel-tint);  color: var(--pi-midnight); }
.status-completed  { background: var(--pi-green-tint);  color: var(--pi-green); }
.status-cancelled  { background: var(--pi-scarlet-tint); color: var(--pi-scarlet); }

/* ----------------------------------------------------------------------------
   Badges — small status/source markers, incl. a "live" pulsing dot
---------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--ds-radius-sm);
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    border: 1px solid transparent;
}

.badge-scarlet { background: var(--pi-scarlet); color: var(--pi-white); }
.badge-navy    { background: var(--pi-midnight); color: var(--pi-white); }
.badge-soft    { background: var(--pi-paper); color: var(--pi-midnight); border-color: var(--pi-border); }
.badge-live    { background: var(--pi-green-tint); color: var(--pi-green); border-color: #bfe3bf; }

.badge-live .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--pi-green);
    animation: pi-pulse-dot 1.6s infinite;
}

@keyframes pi-pulse-dot {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
    .badge-live .dot { animation: none; }
}

/* ----------------------------------------------------------------------------
   Dashboard activity feed (Home, associate view)
---------------------------------------------------------------------------- */
.dash-grid { margin-top: 18px; }

.activity-list { list-style: none; margin: 0; padding: 0; }

.activity-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--pi-border);
    font-size: 0.92rem;
}

.activity-item:last-child { border-bottom: none; }

.activity-time {
    color: var(--pi-steel);
    white-space: nowrap;
    font-size: 0.85rem;
}

/* ----------------------------------------------------------------------------
   Alert / callout items — tinted block with a colored left rule (demo `.alert-item`)
---------------------------------------------------------------------------- */
.alert-item {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--ds-radius-sm);
    margin-bottom: 10px;
    font-size: 0.85rem;
}

.alert-item .alert-icon { flex-shrink: 0; font-size: 16px; line-height: 1.4; }
.alert-item .alert-text strong { display: block; color: var(--pi-midnight); margin-bottom: 2px; }
.alert-item .alert-text span { color: var(--ds-muted); }

.alert-info    { background: var(--pi-info-tint);    border-left: 3px solid var(--pi-info); }
.alert-success { background: var(--pi-green-tint);   border-left: 3px solid var(--pi-green); }
.alert-warning { background: var(--pi-amber-tint);   border-left: 3px solid var(--pi-amber); }
.alert-danger  { background: var(--pi-scarlet-tint); border-left: 3px solid var(--pi-scarlet); }

/* ----------------------------------------------------------------------------
   Empty state
---------------------------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 36px 24px;
    color: var(--ds-muted);
    font-size: 0.9rem;
}

.empty-state .empty-icon { font-size: 30px; opacity: 0.5; margin-bottom: 8px; }

/* ----------------------------------------------------------------------------
   Table refinement — match the demo's airy table (subtle header, row hover)
---------------------------------------------------------------------------- */
.table tbody tr { transition: background 0.12s ease; }
.table tbody tr:hover td { background: #fafafa; }
.table tr:last-child td { border-bottom: none; }

/* ----------------------------------------------------------------------------
   Button refinement — soften corners to the demo's rounded buttons,
   keeping the bold uppercase PI button voice.
---------------------------------------------------------------------------- */
.btn { border-radius: var(--ds-radius-sm); transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
    .btn:hover, .btn:active { transform: none; }
}

/* ----------------------------------------------------------------------------
   Machine cards — dark header over a white body (demo `.mc`)
---------------------------------------------------------------------------- */
.machines-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 18px;
}

.mc {
    background: var(--pi-white);
    border: 2px solid transparent;
    border-radius: var(--ds-radius);
    box-shadow: var(--ds-shadow);
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.mc:hover { transform: translateY(-2px); box-shadow: var(--ds-shadow-lg); }
.mc.active-mc { border-color: var(--pi-scarlet); }

.mc-head {
    background: var(--pi-midnight);
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.mc-head .mc-model {
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--pi-white);
}

.mc-head .mc-category {
    margin-top: 2px;
    font-size: 0.62rem;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}

.mc-body { padding: 16px 18px; }

.mc-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--pi-border);
}

.mc-row:last-child { border-bottom: none; }
.mc-row .mc-k { color: var(--ds-muted); text-transform: uppercase; font-size: 0.66rem; letter-spacing: 0.6px; font-weight: 700; }
.mc-row .mc-v { color: var(--pi-midnight); font-weight: 700; }

/* ----------------------------------------------------------------------------
   Action cards — navigation tiles with a leading icon and a CTA line
   (used on dashboards/landing pages). Builds on .card / .card-link.
---------------------------------------------------------------------------- */
.action-card { display: flex; flex-direction: column; }

.tile-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ds-radius-sm);
    background: var(--pi-scarlet-tint);
    color: var(--pi-scarlet);
    margin-bottom: 12px;
}

.tile-icon svg { width: 22px; height: 22px; display: block; }

.card-cta {
    margin-top: 14px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--pi-midnight);
}

.card-cta::after { content: " \2192"; }
.card-link:hover .card-cta { color: var(--pi-scarlet); }

/* ----------------------------------------------------------------------------
   PI dot pattern utility — the subtle precision pattern from the brand guide.
   Apply to dark surfaces (e.g. hero / banner) for on-brand depth.
---------------------------------------------------------------------------- */
.pi-dot-pattern {
    background-image: radial-gradient(rgba(84, 148, 204, 0.48) 1.3px, transparent 1.7px);
    background-size: 15px 15px;
}

/* Customer/section banner — midnight panel with a scarlet vertical accent line. */
.ds-banner {
    position: relative;
    overflow: hidden;
    background: var(--pi-midnight);
    color: var(--pi-white);
    border-radius: var(--ds-radius);
    padding: 24px 28px 24px 44px;
    margin-bottom: 24px;
}

/* Scarlet vertical line on the left. */
.ds-banner::before {
    content: "";
    position: absolute;
    left: 24px;
    top: 22px;
    bottom: 22px;
    width: 4px;
    border-radius: 2px;
    background: var(--pi-scarlet);
    z-index: 0;
    pointer-events: none;
}

.ds-banner > * { position: relative; z-index: 1; }
.ds-banner-name { font-size: 1.7rem; font-weight: 900; letter-spacing: 0.5px; text-transform: uppercase; line-height: 1.1; }
.ds-banner-sub  { margin-top: 4px; font-size: 0.82rem; color: rgba(255, 255, 255, 0.6); }

/* ============================================================================
   APP SHELL — full-height navy sidebar + white page header
   Overrides the stacked topbar/sidenav layout from app.css. Loaded after
   app.css, so these rules win.
   ========================================================================== */
:root {
    --sidebar-w: 244px;
    --topbar-h: 64px;
}

.app-shell {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
}

/* ---- Sidebar (navy, runs the whole left side) ---- */
.sidebar {
    flex: 0 0 var(--sidebar-w);
    width: var(--sidebar-w);
    background: var(--pi-midnight);
    color: var(--pi-white);
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 14px rgba(4, 23, 63, 0.18);
    z-index: 30;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 20px 18px 16px;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo { height: 38px; width: auto; display: block; }

/* NAV-TOGGLE — the collapsed-menu control. Hidden at desktop widths, where the nav is
   always open; the 900px block below reveals it and hides .sidebar-nav until .nav-open. */
.nav-toggle {
    display: none;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: var(--pi-white);
    padding: 9px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    line-height: 0;
    flex: none;
}

.nav-toggle:hover { background: rgba(255, 255, 255, 0.08); }
.nav-toggle:focus-visible { outline: 2px solid var(--pi-steel); outline-offset: 2px; }

.sidebar-brand-sub {
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 3px;
    color: var(--pi-pewter);
}

/* Nav region fills the middle and scrolls if the menu is long. */
.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px 0;
    overflow-y: auto;
}

.nav-label {
    padding: 14px 18px 5px;
    font-size: 0.56rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.32);
}

/* Light nav items inside the dark sidebar (override app.css dark-on-light). */
.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 18px;
    color: rgba(255, 255, 255, 0.66);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 1px;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-item svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--pi-steel); }

.sidebar-nav .nav-item:hover { background: rgba(255, 255, 255, 0.06); color: var(--pi-white); }

.sidebar-nav .nav-item.active {
    background: rgba(255, 36, 0, 0.16);
    color: var(--pi-white);
    border-left-color: var(--pi-scarlet);
}

/* Customer ("acting as") switcher re-themed for the dark sidebar. */
.sidebar-nav .customer-switcher {
    padding: 12px 16px 14px;
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-nav .customer-switcher-label { color: var(--pi-pewter); }

.sidebar-nav .customer-switcher-select {
    background: var(--pi-midnight);
    border-color: rgba(255, 255, 255, 0.18);
    color: var(--pi-white);
}

/* Sidebar footer — signed-in user identity. */
.sidebar-foot {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sb-user { display: flex; align-items: center; gap: 10px; }

.sb-avatar {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--pi-scarlet);
    color: var(--pi-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
}

.sb-user-info { min-width: 0; }
.sb-user-info .u-name { font-size: 0.78rem; font-weight: 700; color: var(--pi-white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-info .u-sub { font-size: 0.64rem; color: rgba(255, 255, 255, 0.45); }

/* ---- Main area + white page header ---- */
.main-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* Clip (not scroll) any horizontal full-bleed so the viewport-width
       banner can't trigger a horizontal scrollbar. */
    overflow-x: clip;
}

/* ----------------------------------------------------------------------------
   Full-bleed banner — break the .ds-banner out of the content padding and the
   1200px max-width cap so it spans the entire page width beside the sidebar.
---------------------------------------------------------------------------- */
.ds-banner.full-bleed {
    margin-top: -32px;                          /* meet the white top bar */
    margin-left: -40px;                         /* cancel .content left padding */
    width: calc(100vw - var(--sidebar-w));      /* fill the area beside the sidebar */
    max-width: none;
    border-radius: 0;
}

/* Sidebar collapses to a top bar here, so the banner uses the full viewport. */
@media (max-width: 900px) {
    .ds-banner.full-bleed {
        margin-top: -24px;
        margin-left: -20px;
        width: 100vw;
    }
}

@media (max-width: 600px) {
    .ds-banner.full-bleed {
        margin-top: -18px;
        margin-left: -14px;
    }
}

/* Redefine the topbar as a white, sticky page header (was a navy bar in app.css). */
.topbar {
    background: var(--pi-white);
    border-bottom: 1px solid var(--pi-border);
    color: var(--pi-midnight);
    height: var(--topbar-h);
    padding: 0 28px;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 1px 6px rgba(4, 23, 63, 0.05);
}

.topbar-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--pi-midnight);
}

.topbar-logo { height: 34px; width: auto; display: block; }

/* User menu sits in the white header now, so its text must be dark. */
.topbar .user-name { color: var(--pi-midnight); }
.topbar .user-menu-caret { color: var(--pi-pewter); }
.topbar .user-menu-trigger:hover { background: var(--pi-paper); }

/* The user menu deliberately differs between the two portals: the customer portal uses a
   navy panel (see portal-overrides.css there), the internal portal uses the shared white
   menu panel from app.css. That is the ONLY intentional divergence, so it does not live
   here — anything in this file applies to both portals. */

.main-area .content { flex: 1; width: 100%; }

/* Footer: midnight with a scarlet top border to separate it from the page. */
.footer {
    background: var(--pi-midnight);
    border-top: 4px solid var(--pi-scarlet);
    color: rgba(255, 255, 255, 0.88);
}

.footer a { color: #8fb3e0; }
.footer a:hover { color: var(--pi-white); }

/* The badge art is white-on-transparent, so it reads directly on midnight. */
.footer-badge {
    padding: 6px 14px;
}

/* ---- Sidebar collapses to a top bar on small screens ---- */
@media (max-width: 900px) {
    .app-shell { flex-direction: column; }

    .sidebar {
        position: static;
        height: auto;
        width: 100%;
        flex: none;
        box-shadow: 0 2px 10px rgba(4, 23, 63, 0.18);
    }

    /* Brand and toggle share one row; the divider moves to that row so there is only one. */
    .sidebar-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding-right: 14px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .sidebar-brand { flex-direction: row; align-items: center; gap: 12px; border-bottom: none; }
    .sidebar-brand-sub { align-self: center; }

    .nav-toggle { display: inline-flex; }

    /* The hamburger is a bare icon on the navy bar. */
    .nav-toggle { border: none; }

    /* Slide-over drawer from the right; NAV-TOGGLE adds .nav-open to the sidebar to reveal it. */
    .sidebar-nav {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(300px, 85vw);
        display: flex;
        flex-direction: column;
        align-items: stretch;
        overflow-y: auto;
        padding: 16px 0 20px;
        background: var(--pi-midnight);
        box-shadow: -8px 0 24px rgba(4, 23, 63, 0.35);
        transform: translateX(100%);
        visibility: hidden;
        transition: transform 0.22s ease, visibility 0s linear 0.22s;
        z-index: 50;
    }

    .sidebar.nav-open .sidebar-nav {
        transform: translateX(0);
        visibility: visible;
        transition: transform 0.22s ease;
    }

    .nav-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(4, 23, 63, 0.55);
        z-index: 40;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.22s ease;
    }

    .sidebar.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }

    .sidebar-nav .nav-item { padding: 12px 20px; }

    .nav-label { padding: 16px 20px 6px; }
    .sidebar-nav .customer-switcher { border-bottom: none; }
    .sidebar-foot { display: none; }

    .drawer-head { padding: 0 20px 16px; margin-bottom: 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.10); }
    .drawer-close {
        display: block;
        margin-left: auto;
        background: none;
        border: none;
        color: var(--pi-white);
        padding: 4px;
        cursor: pointer;
        line-height: 0;
    }
    .drawer-user { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
    .drawer-avatar {
        flex: none;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.14);
        color: var(--pi-white);
        font-weight: 800;
        font-size: 0.95rem;
    }
    .drawer-user-text { display: flex; flex-direction: column; min-width: 0; }
    .drawer-user-name { font-weight: 800; color: var(--pi-white); overflow: hidden; text-overflow: ellipsis; }
    .drawer-user-link { font-size: 0.8rem; color: var(--pi-pewter); text-decoration: none; }
    .drawer-foot { margin-top: auto; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.10); }
}

/* Mobile-drawer-only pieces (close button, user card, sign out) are hidden when the nav is a sidebar. */
@media (min-width: 901px) {
    .drawer-only, .nav-backdrop { display: none; }
}

/* ============================================================================
   AUTH — full-screen split-screen sign-in (uses AuthLayout, no app chrome)
   ========================================================================== */
.auth-split {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
    background: var(--pi-midnight);
}

/* Left: branded gradient panel with headline + feature facts. */
.auth-brand {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 64px;
    color: var(--pi-white);
    background: var(--pi-midnight);
}

/* Background image on its own layer so we can brighten it. */
.auth-brand::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url('/img/bg-blue-flag.webp') left / cover no-repeat;
    filter: brightness(1.4);
    z-index: 0;
}

/* Dark scrim over the image for headline/body legibility. */
.auth-brand::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(200deg, rgba(4, 23, 63, 0.85) 0%, rgba(4, 23, 63, 0.60) 40%, rgba(4, 23, 63, 0.30) 75%, rgba(4, 23, 63, 0.15) 100%);
    z-index: 0;
    pointer-events: none;
}

.auth-brand-inner { position: relative; z-index: 1; max-width: 460px; }

.auth-logo { height: 46px; width: auto; display: block; margin-bottom: 44px; }

.auth-headline {
    margin: 0 0 16px;
    border: none;
    padding: 0;
    display: block;
    font-size: 2.4rem;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--pi-white);
}

.auth-headline span { color: rgba(255, 255, 255, 0.5); }

/* Scarlet highlight behind a key phrase. box-decoration-break keeps the
   background intact if the phrase wraps across lines. */
.auth-headline .auth-mark {
    color: var(--pi-white);
    background: var(--pi-scarlet);
    padding: 1px 8px;
    border-radius: 4px;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

.auth-sub { margin: 0 0 36px; font-size: 1rem; color: rgba(255, 255, 255, 0.82); max-width: 420px; }

.auth-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }

.auth-fact { display: flex; align-items: center; gap: 14px; color: rgba(255, 255, 255, 0.88); }

.auth-fact-ic {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 9px;
    background: var(--pi-scarlet);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-fact-ic svg { width: 20px; height: 20px; }
.auth-fact strong { display: block; font-size: 1.05rem; font-weight: 800; line-height: 1.1; }
.auth-fact span { font-size: 0.8rem; color: rgba(255, 255, 255, 0.6); }

/* Right: white form panel. */
.auth-panel {
    flex: 0 0 480px;
    max-width: 100%;
    background: var(--pi-white);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px 44px;
    overflow-y: auto;
}

.auth-card { width: 100%; max-width: 380px; margin: 0 auto; }

.auth-card h2 {
    margin: 0 0 4px;
    font-size: 1.5rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--pi-midnight);
}

.auth-card-sub { margin: 0 0 24px; color: var(--ds-muted); font-size: 0.9rem; }

.auth-note { margin-top: 18px; font-size: 0.8rem; color: var(--ds-muted); }

.auth-associate {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--pi-border);
    text-align: center;
    font-size: 0.8rem;
    color: var(--ds-muted);
}

.auth-associate a { color: var(--pi-midnight); font-weight: 700; }
.auth-associate a:hover { color: var(--pi-scarlet); }

@media (max-width: 860px) {
    .auth-split { flex-direction: column; }
    .auth-brand { padding: 40px 28px; }
    .auth-headline { font-size: 1.8rem; }
    .auth-panel { flex: 1; width: 100%; padding: 36px 24px; }
}

@media (max-width: 560px) {
    .auth-facts { display: none; }
    .auth-sub { margin-bottom: 0; }
}

/* --------------------------- Idle session timeout -------------------------
   The warning dialog idle-timeout.js raises shortly before an inactive session
   is signed out. Deliberately plain DOM rather than a Blazor component: it has
   to still work after the circuit has dropped, which is exactly when an idle
   tab tends to be sitting.
-------------------------------------------------------------------------- */
.pi-idle-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(4, 23, 63, 0.55);
}

/* The page behind the dialog must not scroll away underneath it. */
body.pi-idle-locked { overflow: hidden; }

.pi-idle-dialog {
    width: 100%;
    max-width: 420px;
    background: var(--pi-white);
    color: var(--pi-ink);
    border-top: 4px solid var(--pi-scarlet);
    border-radius: var(--ds-radius);
    box-shadow: var(--ds-shadow-lg);
    padding: 28px 26px 24px;
}

.pi-idle-title {
    margin: 0 0 8px;
    font-size: 1.25rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--pi-midnight);
}

.pi-idle-body {
    margin: 0 0 22px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--ds-muted);
}

/* Tabular figures so the countdown does not jitter as the digits change. */
.pi-idle-countdown {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--pi-midnight);
}

.pi-idle-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.pi-idle-out { color: var(--pi-midnight); }

/* Visually hidden — carries the countdown announcements for screen readers. */
.pi-idle-announce {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 420px) {
    .pi-idle-actions { flex-direction: column; align-items: stretch; }
    .pi-idle-actions .btn { text-align: center; }
}

/* ------------------------------ Responsive -------------------------------- */
@media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px)  { .grid-2, .grid-2-eq { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px)  { .kpi-row { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: 1fr; } .topbar { padding: 0 16px; } }
