/**
 * TrackStage PWA / Mobile Experience — Sprint 3.3 + 3.4
 * Safe areas, viewport height, form zoom prevention, splash, standalone,
 * bottom navigation, drawer, and mobile touch chrome.
 */
:root {
    --ts-bg: #08111d;
    --ts-safe-top: env(safe-area-inset-top, 0px);
    --ts-safe-right: env(safe-area-inset-right, 0px);
    --ts-safe-bottom: env(safe-area-inset-bottom, 0px);
    --ts-safe-left: env(safe-area-inset-left, 0px);
    --ts-vh: 1vh;
    --ts-bottom-nav-h: 4.25rem;
    --ts-mobile-max: 1279px;
    --ts-install-banner-h: 0px;

    /* RC-01.04 — Overlay layer hierarchy */
    --ts-z-content: 1;
    --ts-z-content-raised: 10;
    --ts-z-sticky: 500;
    --ts-z-dropdown: 1000;
    --ts-z-fab: 1100;
    --ts-z-popover: 1200;
    --ts-z-drawer: 1500;
    --ts-z-modal: 2000;
    --ts-z-toast: 3000;
    --ts-z-loading: 9999;
}

/* Legacy iOS (constant) before env() became standard */
@supports (padding: constant(safe-area-inset-top)) {
    :root {
        --ts-safe-top: constant(safe-area-inset-top);
        --ts-safe-right: constant(safe-area-inset-right);
        --ts-safe-bottom: constant(safe-area-inset-bottom);
        --ts-safe-left: constant(safe-area-inset-left);
    }
}

@supports (padding: env(safe-area-inset-top)) {
    :root {
        --ts-safe-top: env(safe-area-inset-top, 0px);
        --ts-safe-right: env(safe-area-inset-right, 0px);
        --ts-safe-bottom: env(safe-area-inset-bottom, 0px);
        --ts-safe-left: env(safe-area-inset-left, 0px);
    }
}

@supports (height: 100dvh) {
    :root {
        --ts-vh: 1dvh;
    }
}

html {
    background-color: var(--ts-bg);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html.ts-standalone body,
body {
    background-color: #000;
    min-height: calc(var(--ts-vh, 1vh) * 100);
    padding-top: var(--ts-safe-top);
    padding-right: var(--ts-safe-right);
    padding-bottom: var(--ts-safe-bottom);
    padding-left: var(--ts-safe-left);
    overscroll-behavior-y: contain;
}

/* Mobile shell: reserve space for fixed bottom nav */
@media (max-width: 1279px) {
    body.ts-app-shell {
        padding-bottom: calc(var(--ts-bottom-nav-h) + var(--ts-safe-bottom));
    }

    .ts-main {
        padding-bottom: 1.25rem;
    }

    .ts-mobile-footer-pad {
        padding-bottom: 0.5rem;
    }
}

/* Prevent iOS Safari zoom on form focus (needs >= 16px). */
input,
select,
textarea,
button {
    font-size: 16px;
}

@media (min-width: 768px) {
    input,
    select,
    textarea,
    button {
        font-size: inherit;
    }
}

/* Smooth scrolling without trapping camera / QR panels. */
main {
    -webkit-overflow-scrolling: touch;
}

/* Install CTA — compact header (authenticated shell) */
[data-ts-install][hidden],
[data-ts-install-banner][hidden] {
    display: none !important;
}

.ts-install-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(59, 130, 246, 0.55);
    background: rgba(59, 130, 246, 0.15);
    padding: 0.5rem 0.9rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #93c5fd;
    white-space: nowrap;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.ts-install-btn:hover {
    background: rgba(59, 130, 246, 0.28);
    border-color: rgba(59, 130, 246, 0.85);
}

/* Compact install suggestion — visual only; install logic unchanged */
.ts-install-banner {
    position: fixed;
    z-index: var(--ts-z-popover, 1200);
    left: max(0.75rem, var(--ts-safe-left));
    right: max(0.75rem, var(--ts-safe-right));
    bottom: calc(var(--ts-safe-bottom) + 0.75rem);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.55rem;
    min-height: 3.15rem;
    padding: 0.4rem 0.4rem 0.4rem 0.55rem;
    border-radius: 0.7rem;
    border: 1px solid rgba(59, 130, 246, 0.28);
    background: rgba(10, 15, 28, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.32),
        0 0 0 1px rgba(15, 23, 42, 0.65);
    animation: ts-install-in 0.25s ease both;
}

@media (max-width: 1279px) {
    body.ts-app-shell .ts-install-banner {
        bottom: calc(var(--ts-bottom-nav-h) + var(--ts-safe-bottom) + 5.35rem);
    }
}

html.ts-install-banner-visible .ts-guest-frame {
    padding-bottom: calc(4.25rem + var(--ts-safe-bottom));
}

.ts-install-banner-dismiss {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.85rem;
    height: 1.85rem;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.65);
    color: #94a3b8;
}

.ts-install-banner-body {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
    flex: 1 1 auto;
}

.ts-install-banner-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.45rem;
    border: 1px solid rgba(59, 130, 246, 0.3);
    background: #08111d;
    flex-shrink: 0;
    object-fit: cover;
}

.ts-install-banner-copy {
    min-width: 0;
    flex: 1 1 auto;
}

.ts-install-banner-title {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-install-banner-sub {
    margin: 0.05rem 0 0;
    font-size: 0.75rem;
    line-height: 1.2;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-install-banner-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-height: 2rem;
    height: 2rem;
    width: auto;
    padding: 0 0.8rem;
    border: 0;
    border-radius: 0.45rem;
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.28);
    transition: transform 0.2s ease, filter 0.2s ease;
}

.ts-install-banner-cta:active {
    transform: scale(0.98);
}

@media (max-width: 479px) {
    .ts-install-banner {
        gap: 0.4rem;
        padding: 0.3rem 0.3rem 0.3rem 0.45rem;
    }

    .ts-install-banner-sub {
        display: none;
    }
}

@keyframes ts-install-in {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Splash — avoid white flash; match theme #08111d */
#ts-pwa-splash[hidden] {
    display: none !important;
}

#ts-pwa-splash {
    position: fixed;
    inset: 0;
    z-index: var(--ts-z-loading, 9999);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding:
        calc(1.5rem + var(--ts-safe-top))
        1.25rem
        calc(1.5rem + var(--ts-safe-bottom));
    background: var(--ts-bg);
    color: #e2e8f0;
    text-align: center;
    transition: opacity 0.45s ease, visibility 0.45s ease;
}

#ts-pwa-splash.ts-splash-hide {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ts-splash-glow {
    position: absolute;
    width: 18rem;
    height: 18rem;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.28), transparent 68%);
    pointer-events: none;
    animation: ts-splash-pulse 1.6s ease-in-out infinite;
}

.ts-splash-logo {
    position: relative;
    width: 112px;
    height: 112px;
    margin-bottom: 1.35rem;
    border-radius: 1.5rem;
    animation: ts-splash-logo-in 0.45s ease both;
}

#ts-pwa-splash .ts-splash-title {
    position: relative;
    margin: 0;
    font-size: 1.65rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    color: #fff;
    animation: ts-splash-logo-in 0.5s ease 0.05s both;
}

#ts-pwa-splash .ts-splash-tagline {
    position: relative;
    margin: 0.75rem 0 0;
    max-width: 18rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #94a3b8;
    animation: ts-splash-logo-in 0.55s ease 0.1s both;
}

.ts-splash-progress {
    position: relative;
    margin-top: 1.75rem;
    width: 7.5rem;
    height: 0.2rem;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(51, 65, 85, 0.85);
}

.ts-splash-progress span {
    display: block;
    height: 100%;
    width: 40%;
    border-radius: inherit;
    background: #3b82f6;
    animation: ts-splash-bar 1.1s ease-in-out infinite;
}

@keyframes ts-splash-logo-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes ts-splash-pulse {
    0%, 100% { opacity: 0.55; transform: scale(1); }
    50% { opacity: 0.9; transform: scale(1.06); }
}

@keyframes ts-splash-bar {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(280%); }
}

/* PWA diagnostics */
[data-ts-pwa-status] [data-check] {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid rgba(30, 41, 59, 0.9);
    font-size: 0.875rem;
}

[data-ts-pwa-status] [data-check]:last-child {
    border-bottom: 0;
}

[data-ts-pwa-status] [data-mark] {
    width: 1.25rem;
    text-align: center;
    color: #64748b;
}

[data-ts-pwa-status] [data-check][data-state="ok"] [data-mark] {
    color: #22c55e;
}

[data-ts-pwa-status] [data-check][data-state="pending"] [data-mark] {
    color: #64748b;
}

/* Standalone: hide browser chrome affordances where useful */
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
    .ts-browser-only {
        display: none !important;
    }

    html.ts-standalone body,
    body {
        /* Native app feel — no rubber-band into browser chrome */
        overscroll-behavior: none;
    }
}

/* =========================================================
   Sprint 3.4 — Mobile Experience chrome
   ========================================================= */

.ts-mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--ts-z-sticky, 500);
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    min-height: var(--ts-bottom-nav-h);
    padding:
        0.35rem
        max(0.35rem, var(--ts-safe-left))
        calc(0.35rem + var(--ts-safe-bottom))
        max(0.35rem, var(--ts-safe-right));
    border-top: 1px solid rgba(30, 41, 59, 0.95);
    background: rgba(10, 15, 28, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.35);
}

.ts-bottom-tab {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-height: 3.25rem;
    min-width: 0;
    padding: 0.35rem 0.25rem;
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease;
}

.ts-bottom-tab span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ts-bottom-icon {
    width: 1.35rem;
    height: 1.35rem;
    flex-shrink: 0;
}

.ts-bottom-tab.is-active,
.ts-bottom-tab[aria-current="page"] {
    color: #60a5fa;
}

.ts-bottom-tab:active {
    color: #93c5fd;
}

/* Drawer */
.ts-mobile-drawer {
    position: fixed;
    inset: 0;
    z-index: var(--ts-z-drawer, 1500);
}

.ts-mobile-drawer[hidden] {
    display: none !important;
}

.ts-drawer-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ts-drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(22rem, 88vw);
    display: flex;
    flex-direction: column;
    background: #0a0f1c;
    border-left: 1px solid rgba(30, 41, 59, 0.95);
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
    transform: translateX(104%);
    transition: transform 0.22s ease;
    padding-top: var(--ts-safe-top);
    padding-bottom: var(--ts-safe-bottom);
}

.ts-mobile-drawer.is-open .ts-drawer-backdrop {
    opacity: 1;
}

.ts-mobile-drawer.is-open .ts-drawer-panel {
    transform: translateX(0);
}

html.ts-drawer-open {
    overflow: hidden;
}

.ts-drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1rem 0.85rem;
    border-bottom: 1px solid rgba(30, 41, 59, 0.9);
}

.ts-drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(51, 65, 85, 0.9);
    background: rgba(15, 23, 42, 0.8);
    color: #cbd5e1;
}

.ts-drawer-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.75rem 1rem 1.5rem;
}

.ts-drawer-section {
    margin-bottom: 1.25rem;
}

.ts-drawer-label {
    margin: 0 0 0.45rem;
    padding: 0 0.25rem;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #64748b;
}

.ts-drawer-link {
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: 0.75rem;
    border: 1px solid transparent;
    color: #cbd5e1;
    font-size: 0.9375rem;
    text-decoration: none;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.ts-drawer-link:hover,
.ts-drawer-link:focus-visible {
    background: rgba(15, 23, 42, 0.9);
    border-color: rgba(51, 65, 85, 0.8);
    color: #fff;
    outline: none;
}

.ts-drawer-link.is-active {
    border-color: rgba(59, 130, 246, 0.45);
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
}

.ts-drawer-link-accent {
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.08);
    color: #4ade80;
}

/* Mobile list cards (replace tables below xl) */
.ts-mobile-card-list {
    display: flex;
    flex-direction: column;
    gap: 1rem; /* 16px breathing room */
}

.ts-mobile-card {
    display: block;
    padding: 1.15rem 1.1rem;
    border-radius: 1rem;
    border: 1px solid rgba(30, 41, 59, 0.95);
    background: rgba(2, 6, 23, 0.65);
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    transition:
        transform 0.22s ease,
        border-color 0.22s ease,
        box-shadow 0.22s ease,
        background 0.22s ease;
}

.ts-mobile-card:active {
    border-color: rgba(59, 130, 246, 0.45);
    transform: scale(0.985);
}

a.ts-mobile-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
}

.ts-mobile-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
}

.ts-mobile-card-meta {
    margin-top: 0.35rem;
    font-size: 0.8125rem;
    color: #94a3b8;
}

.ts-mobile-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.95rem;
}

.ts-mobile-card-actions a,
.ts-mobile-card-actions button,
.ts-touch-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3rem; /* 48px */
    padding: 0.55rem 0.95rem;
    border-radius: 0.75rem;
    border-width: 1px;
    border-style: solid;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.ts-touch-btn:active {
    transform: scale(0.97);
}

/* Primary Scanner card — Home hero */
.ts-scanner-primary {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    min-height: 11rem;
    padding: 1.75rem 1.35rem;
    border-radius: 1.35rem;
    border: 1px solid rgba(59, 130, 246, 0.55);
    background:
        radial-gradient(circle at 50% 18%, rgba(59, 130, 246, 0.32), transparent 52%),
        rgba(8, 17, 29, 0.92);
    box-shadow:
        0 0 36px rgba(59, 130, 246, 0.26),
        0 12px 28px rgba(0, 0, 0, 0.35);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    will-change: transform;
}

.ts-scanner-hero {
    min-height: 12rem;
}

.ts-scanner-primary:active,
.ts-tap:active {
    transform: scale(0.97);
}

.ts-scanner-primary-glow {
    position: absolute;
    top: 12%;
    left: 50%;
    width: 9rem;
    height: 9rem;
    margin-left: -4.5rem;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(96, 165, 250, 0.45), transparent 68%);
    pointer-events: none;
    animation: ts-glow-breathe 2.8s ease-in-out infinite;
}

.ts-scanner-primary-icon {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4.25rem;
    height: 4.25rem;
    border-radius: 1.25rem;
    border: 1px solid rgba(59, 130, 246, 0.55);
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    box-shadow: 0 0 24px rgba(59, 130, 246, 0.35);
}

.ts-scanner-primary-title {
    position: relative;
    z-index: 1;
    margin-top: 1rem;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #fff;
}

.ts-scanner-primary-sub {
    position: relative;
    z-index: 1;
    margin-top: 0.35rem;
    max-width: 16rem;
    font-size: 0.875rem;
    line-height: 1.35;
    color: rgba(147, 197, 253, 0.92);
}

/* Evento Atual — Operation Mode */
.ts-evento-atual {
    padding: 1.25rem 1.2rem 1.2rem;
    border-radius: 1.2rem;
    border: 1px solid rgba(59, 130, 246, 0.4);
    background:
        linear-gradient(180deg, rgba(59, 130, 246, 0.12), transparent 55%),
        rgba(2, 6, 23, 0.82);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

.ts-evento-atual-eyebrow {
    margin: 0;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #60a5fa;
}

.ts-evento-atual-name {
    margin: 0.55rem 0 0;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
    line-height: 1.25;
}

.ts-evento-atual-city {
    margin: 0.35rem 0 0;
    font-size: 0.9375rem;
    color: #94a3b8;
}

.ts-evento-atual-status {
    margin: 0.75rem 0 0;
    font-size: 0.875rem;
    color: #64748b;
}

.ts-evento-atual-status span {
    color: #4ade80;
    font-weight: 600;
}

.ts-ops-quick-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.ts-ops-quick {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    min-height: 6.5rem;
    padding: 1rem 0.95rem;
    border-radius: 1.1rem;
    border: 1px solid rgba(51, 65, 85, 0.9);
    background: rgba(2, 6, 23, 0.72);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    will-change: transform;
}

.ts-ops-quick-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.85rem;
    border: 1px solid rgba(51, 65, 85, 0.9);
    background: rgba(15, 23, 42, 0.85);
}

.ts-ops-quick-label {
    font-size: 0.95rem;
    font-weight: 650;
    line-height: 1.2;
    color: #e2e8f0;
}

.ts-ops-quick--scan {
    border-color: rgba(59, 130, 246, 0.45);
    background: rgba(59, 130, 246, 0.1);
}
.ts-ops-quick--scan .ts-ops-quick-icon { color: #60a5fa; border-color: rgba(59, 130, 246, 0.4); background: rgba(59, 130, 246, 0.15); }

.ts-ops-quick--carga {
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.08);
}
.ts-ops-quick--carga .ts-ops-quick-icon { color: #4ade80; border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.12); }

.ts-ops-quick--incidente {
    border-color: rgba(248, 113, 113, 0.4);
    background: rgba(248, 113, 113, 0.08);
}
.ts-ops-quick--incidente .ts-ops-quick-icon { color: #fca5a5; border-color: rgba(248, 113, 113, 0.35); background: rgba(248, 113, 113, 0.12); }

.ts-ops-quick--retorno {
    border-color: rgba(251, 191, 36, 0.4);
    background: rgba(251, 191, 36, 0.08);
}
.ts-ops-quick--retorno .ts-ops-quick-icon { color: #fcd34d; border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.12); }

/* Ops status under logo */
.ts-ops-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin: 0.3rem auto 0;
    max-width: 100%;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-ops-status-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    flex-shrink: 0;
}

.ts-ops-status--neon {
    color: #86efac;
    background: rgba(34, 197, 94, 0.12);
}
.ts-ops-status--neon .ts-ops-status-dot {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
}

.ts-ops-status--amber {
    color: #fcd34d;
    background: rgba(245, 158, 11, 0.12);
}
.ts-ops-status--amber .ts-ops-status-dot {
    background: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.7);
}

.ts-ops-status--slate {
    color: #94a3b8;
    background: rgba(51, 65, 85, 0.35);
}
.ts-ops-status--slate .ts-ops-status-dot {
    background: #64748b;
}

/* Floating Action Button — Smart FAB */
.ts-scan-fab {
    position: fixed;
    z-index: var(--ts-z-fab, 1100);
    right: max(1rem, var(--ts-safe-right));
    bottom: calc(var(--ts-bottom-nav-h) + var(--ts-safe-bottom) + 1.25rem); /* ~20px above nav */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.85rem;
    height: 3.85rem;
    border-radius: 999px;
    border: 1px solid rgba(147, 197, 253, 0.7);
    background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow:
        0 12px 28px rgba(37, 99, 235, 0.5),
        0 0 0 5px rgba(59, 130, 246, 0.16),
        0 0 32px rgba(59, 130, 246, 0.45);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: ts-fab-in 0.24s ease both, ts-fab-pulse 0.9s ease 0.28s 1;
    will-change: transform;
}

.ts-scan-fab-glow {
    position: absolute;
    inset: -6px;
    border-radius: inherit;
    background: radial-gradient(circle, rgba(96, 165, 250, 0.45), transparent 70%);
    pointer-events: none;
    opacity: 0.85;
}

.ts-scan-fab svg {
    position: relative;
    z-index: 1;
}

.ts-scan-fab:active {
    transform: scale(0.92);
}

@keyframes ts-fab-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.86);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes ts-fab-pulse {
    0% { box-shadow: 0 12px 28px rgba(37, 99, 235, 0.5), 0 0 0 5px rgba(59, 130, 246, 0.16), 0 0 32px rgba(59, 130, 246, 0.45); }
    50% { box-shadow: 0 12px 28px rgba(37, 99, 235, 0.55), 0 0 0 10px rgba(59, 130, 246, 0.08), 0 0 40px rgba(59, 130, 246, 0.65); }
    100% { box-shadow: 0 12px 28px rgba(37, 99, 235, 0.5), 0 0 0 5px rgba(59, 130, 246, 0.16), 0 0 32px rgba(59, 130, 246, 0.45); }
}

@keyframes ts-glow-breathe {
    0%, 100% { opacity: 0.55; transform: scale(1); }
    50% { opacity: 0.95; transform: scale(1.08); }
}

.ts-card-enter {
    animation: ts-card-in 0.22s ease both;
}

@keyframes ts-card-in {
    from {
        opacity: 0;
        transform: translate3d(0, 10px, 0);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.ts-mobile-shortcut {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 5.85rem;
    padding: 1.1rem 1rem;
    border-radius: 1.05rem;
    border-width: 1px;
    border-style: solid;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    will-change: auto;
}

.ts-mobile-shortcut:active {
    transform: scale(0.97);
    will-change: transform;
}

.ts-bottom-tab {
    transition: color 0.22s ease, transform 0.2s ease;
}

.ts-bottom-tab:active {
    transform: translateY(1px);
}

.ts-drawer-backdrop {
    transition: opacity 0.22s ease;
}

.ts-drawer-panel {
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.ts-drawer-link {
    min-height: 3rem;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* Mobile forms — larger touch targets */
@media (max-width: 1279px) {
    .ts-main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    .ts-main select,
    .ts-main textarea {
        min-height: 3rem;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .ts-main button[type="submit"],
    .ts-main .ts-touch-btn {
        min-height: 3rem;
    }

    .ts-ops-actions {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .ts-ops-actions > * {
        width: 100%;
        justify-content: center;
    }

    /* Keep FAB clear of content */
    .ts-main {
        padding-right: 0.25rem;
    }
}

/* Sticky QR affordance on operational screens */
.ts-qr-mobile-cta {
    position: sticky;
    top: 0.5rem;
    z-index: 20;
}

@media (min-width: 1280px) {
    .ts-qr-mobile-cta {
        position: static;
    }
}

/* Lazy paint for heavy dashboard / table regions */
.ts-lazy-panel {
    content-visibility: auto;
    contain-intrinsic-size: 480px;
}

/* Wizard steps (mobile forms) */
.ts-wizard-steps {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.ts-wizard-step-dot {
    flex: 1;
    height: 0.35rem;
    border-radius: 999px;
    background: rgba(51, 65, 85, 0.9);
}

.ts-wizard-step-dot.is-active {
    background: #3b82f6;
}

.ts-wizard-step-dot.is-done {
    background: #22c55e;
}

[data-ts-wizard-panel][hidden] {
    display: none !important;
}

/* ============================================================
 * RC-01.12 — Full Screen Operational QR Scanner
 * ============================================================ */

body.ts-scan-immersive {
    overflow: hidden !important;
    overscroll-behavior: none;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

body.ts-scan-immersive .ts-sidebar,
body.ts-scan-immersive .ts-topbar,
body.ts-scan-immersive .ts-mobile-bottom-nav,
body.ts-scan-immersive .ts-scan-fab,
body.ts-scan-immersive .ts-mobile-footer-pad,
body.ts-scan-immersive footer,
body.ts-scan-immersive .ts-shell-bg,
body.ts-scan-immersive #ts-mobile-drawer,
body.ts-scan-immersive .ts-pwa-install-banner,
body.ts-scan-immersive .ts-toast-host,
body.ts-scan-immersive .ts-flash {
    display: none !important;
}

body.ts-scan-immersive .ts-main {
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}

body.ts-scan-immersive .ts-shell-frame,
body.ts-scan-immersive .ts-shell-column {
    min-height: 100dvh;
}

body.ts-scan-immersive .ts-qr-root {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
}

body.ts-scan-immersive .ts-qr-idle {
    display: none !important;
}

body.ts-scan-immersive .ts-main > *:not(.ts-qr-mobile-cta) {
    visibility: hidden !important;
    pointer-events: none !important;
}

body.ts-scan-immersive .ts-qr-mobile-cta {
    position: static !important;
    margin: 0 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.ts-qr-immersive {
    position: fixed;
    inset: 0;
    z-index: calc(var(--ts-z-modal) + 40);
    width: 100%;
    height: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #000;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

.ts-qr-immersive.hidden {
    display: none !important;
}

.ts-qr-reader {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    border: 0;
    border-radius: 0;
    max-width: none;
}

.ts-qr-reader video,
.ts-qr-reader canvas,
.ts-qr-reader img {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    object-fit: cover !important;
    border: 0 !important;
    border-radius: 0 !important;
}

/* Hide library dark overlay — camera stays fully visible */
.ts-qr-reader #qr-shaded-region,
.ts-qr-reader [id$="qr-shaded-region"],
.ts-qr-immersive #qr-shaded-region {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    outline: none !important;
}

.ts-qr-reader #qr-shaded-region > div,
.ts-qr-immersive #qr-shaded-region > div {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Centered scanning guide — thin white corners, no dark veil */
.ts-qr-guide {
    position: absolute;
    left: 50%;
    top: 42%;
    width: min(72vw, 280px);
    height: min(72vw, 280px);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 2;
}

.ts-qr-guide-corner {
    position: absolute;
    width: 28px;
    height: 28px;
    border: 2px solid rgba(255, 255, 255, 0.92);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.ts-qr-guide-tl {
    top: 0;
    left: 0;
    border-right: 0;
    border-bottom: 0;
}

.ts-qr-guide-tr {
    top: 0;
    right: 0;
    border-left: 0;
    border-bottom: 0;
}

.ts-qr-guide-bl {
    bottom: 0;
    left: 0;
    border-right: 0;
    border-top: 0;
}

.ts-qr-guide-br {
    bottom: 0;
    right: 0;
    border-left: 0;
    border-top: 0;
}

.ts-qr-flash-layer {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    transition: opacity 80ms linear;
    background: transparent;
}

.ts-qr-flash-layer.is-success {
    background: rgba(34, 197, 94, 0.55);
    opacity: 1;
}

.ts-qr-flash-layer.is-duplicate {
    background: rgba(245, 158, 11, 0.55);
    opacity: 1;
}

.ts-qr-flash-layer.is-error {
    background: rgba(239, 68, 68, 0.55);
    opacity: 1;
}

.ts-qr-feedback {
    position: absolute;
    left: 50%;
    top: 42%;
    z-index: 6;
    transform: translate(-50%, -50%);
    max-width: min(88vw, 320px);
    padding: 0.85rem 1.15rem;
    border-radius: 0.75rem;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #fff;
    background: rgba(8, 17, 29, 0.72);
    backdrop-filter: blur(6px);
    pointer-events: none;
    opacity: 0;
    transition: opacity 180ms ease;
    white-space: pre-line;
    line-height: 1.35;
}

.ts-qr-feedback.is-visible {
    opacity: 1;
}

.ts-qr-feedback.is-success {
    color: #bbf7d0;
}

.ts-qr-feedback.is-duplicate {
    color: #fde68a;
}

.ts-qr-feedback.is-error {
    color: #fecaca;
}

.ts-qr-exit {
    position: absolute;
    top: calc(0.75rem + var(--ts-safe-top));
    left: calc(0.75rem + var(--ts-safe-left));
    z-index: 7;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(8, 17, 29, 0.55);
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.8rem;
    font-weight: 500;
    backdrop-filter: blur(8px);
    -webkit-tap-highlight-color: transparent;
}

.ts-qr-exit-x {
    font-size: 0.95rem;
    line-height: 1;
    opacity: 0.9;
}

.ts-qr-torch {
    position: absolute;
    top: calc(0.75rem + var(--ts-safe-top));
    right: calc(0.75rem + var(--ts-safe-right));
    z-index: 7;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(8, 17, 29, 0.55);
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.8rem;
    font-weight: 500;
    backdrop-filter: blur(8px);
    -webkit-tap-highlight-color: transparent;
}

.ts-qr-torch.is-on {
    border-color: rgba(250, 204, 21, 0.55);
    background: rgba(250, 204, 21, 0.18);
    color: #fef08a;
}

/* RC-01.13 — Guided expected item banner (top of immersive scanner) */
.ts-qr-expected {
    position: absolute;
    top: calc(3.6rem + var(--ts-safe-top));
    left: 50%;
    z-index: 7;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    min-width: min(72vw, 260px);
    max-width: min(88vw, 340px);
    padding: 0.65rem 1rem;
    border-radius: 0.85rem;
    border: 1px solid rgba(56, 189, 248, 0.35);
    background: rgba(8, 17, 29, 0.72);
    backdrop-filter: blur(10px);
    text-align: center;
    pointer-events: none;
}

.ts-qr-expected-label {
    font-size: 0.65rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(125, 211, 252, 0.9);
    font-weight: 600;
}

.ts-qr-expected-name {
    font-size: 1rem;
    font-weight: 650;
    color: #f8fafc;
    line-height: 1.25;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ts-qr-expected-name.hidden {
    display: none;
}

.ts-qr-expected-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.95rem;
    font-weight: 600;
    color: #7dd3fc;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ts-qr-guided .ts-qr-guide-corner {
    border-color: rgba(56, 189, 248, 0.85);
}

/* Per-row guided QR open button */
.ts-guided-scan-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
    -webkit-tap-highlight-color: transparent;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.ts-guided-scan-btn:hover,
.ts-guided-scan-btn:focus-visible {
    background: rgba(34, 197, 94, 0.22);
    border-color: rgba(34, 197, 94, 0.65);
    color: #bbf7d0;
    outline: none;
}

.ts-guided-scan-btn--table {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.65rem;
}

.ts-qr-hud {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 7;
    max-height: 25vh;
    padding:
        0.55rem
        calc(0.75rem + var(--ts-safe-right))
        calc(0.75rem + var(--ts-safe-bottom))
        calc(0.75rem + var(--ts-safe-left));
    background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.48) 72%, transparent 100%);
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.45rem;
}

/* RC-01.14 — Operational Guidance Panel */
.ts-qr-guidance {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    flex-shrink: 0;
}

.ts-qr-guide-card {
    min-width: 0;
    padding: 0.4rem 0.5rem 0.45rem;
    border-radius: 0.65rem;
    background: rgba(8, 17, 29, 0.55);
    backdrop-filter: blur(8px);
}

.ts-qr-guide-card--last {
    border: 1px solid rgba(34, 197, 94, 0.55);
}

.ts-qr-guide-card--next {
    border: 1px solid rgba(56, 189, 248, 0.7);
    background: rgba(14, 116, 144, 0.28);
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.12);
}

.ts-qr-guide-card--next.is-complete {
    border-color: rgba(250, 204, 21, 0.55);
    background: rgba(113, 63, 18, 0.35);
    box-shadow: none;
}

.ts-qr-guide-card-head {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.2rem;
}

.ts-qr-guide-card-icon {
    font-size: 0.75rem;
    line-height: 1;
    flex-shrink: 0;
}

.ts-qr-guide-card--last .ts-qr-guide-card-icon {
    color: #4ade80;
}

.ts-qr-guide-card--next .ts-qr-guide-card-icon {
    color: #7dd3fc;
}

.ts-qr-guide-card--next.is-complete .ts-qr-guide-card-icon {
    color: #fde68a;
}

.ts-qr-guide-card-label {
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 650;
}

.ts-qr-guide-card--last .ts-qr-guide-card-label {
    color: #86efac;
}

.ts-qr-guide-card--next .ts-qr-guide-card-label {
    color: #bae6fd;
}

.ts-qr-guide-card--next.is-complete .ts-qr-guide-card-label {
    color: #fde68a;
}

.ts-qr-guide-card-name,
.ts-qr-guide-card-code,
.ts-qr-guide-card-done-msg {
    margin: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ts-qr-guide-card-name {
    font-size: 0.78rem;
    font-weight: 650;
    color: #f8fafc;
    line-height: 1.2;
}

.ts-qr-guide-card-name.is-empty {
    display: none;
}

.ts-qr-guide-card-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(226, 232, 240, 0.88);
    line-height: 1.25;
    margin-top: 0.1rem;
}

.ts-qr-guide-card-code.hidden {
    display: none;
}

.ts-qr-guide-card--next .ts-qr-guide-card-code {
    color: #e0f2fe;
}

.ts-qr-guide-card-done-msg {
    margin-top: 0.15rem;
    font-size: 0.68rem;
    font-weight: 500;
    color: #fef3c7;
    white-space: normal;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.ts-qr-guide-card-done-msg.hidden {
    display: none;
}

.ts-qr-progress {
    flex-shrink: 0;
}

.ts-qr-progress-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.3rem;
}

.ts-qr-progress-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: rgba(248, 250, 252, 0.92);
}

.ts-qr-progress-ratio {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
}

.ts-qr-progress-track {
    height: 0.4rem;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.35);
}

.ts-qr-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: #22c55e;
    transition: width 180ms ease;
}

.ts-qr-status {
    position: absolute;
    left: 50%;
    bottom: calc(24vh + var(--ts-safe-bottom));
    z-index: 6;
    transform: translateX(-50%);
    max-width: min(90vw, 360px);
    margin: 0;
    padding: 0.35rem 0.65rem;
    border-radius: 0.5rem;
    text-align: center;
    font-size: 0.7rem;
    line-height: 1.3;
    color: rgba(226, 232, 240, 0.75);
    background: rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.ts-qr-status:empty {
    display: none;
}

.ts-qr-immersive [data-qr-camera-diag] {
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(26vh + var(--ts-safe-bottom));
    z-index: 8;
    max-height: 40vh;
}
