:root {
    --mobile-shell-width: 768px;
    --stack-gap: 18px;
    --card-radius: 10px;
    --card-padding: 24px;
    --bs-body-font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    --bs-body-color: #1f2a37;
    --bs-primary: #336699;
    --bs-primary-rgb: 51, 102, 153;
    --zapp-navy: #10253d;
    --zapp-blue: #336699;
    --zapp-blue-dark: #20476d;
    --zapp-muted-bg: #e9eef5;
    --zapp-muted-border: #d4dee9;
    --zapp-muted-color: #526070;
    --zapp-surface: rgba(255, 255, 255, 0.92);
    --zapp-shadow: 0 18px 45px rgba(31, 42, 55, 0.08);
}

[ng-cloak],
.ng-cloak {
    display: none !important;
}

.btn-primary {
    --bs-btn-bg: var(--zapp-blue);
    --bs-btn-border-color: var(--zapp-blue);
    --bs-btn-hover-bg: var(--zapp-blue-dark);
    --bs-btn-hover-border-color: var(--zapp-blue-dark);
    --bs-btn-active-bg: var(--zapp-navy);
    --bs-btn-active-border-color: var(--zapp-navy);
}

.text-primary {
    color: var(--zapp-blue) !important;
}

html,
body {
    min-height: 100%;
    margin: 0;
    font-family: var(--bs-body-font-family);
    color: var(--bs-body-color);
    background: linear-gradient(180deg, #eef4fb 0%, #dde8f5 100%);
}

body {
    overflow-x: hidden;
}

body.audit-auth-mode {
    background:
        radial-gradient(circle at 18% 20%, rgba(255, 198, 120, 0.34) 0, rgba(255, 198, 120, 0) 28%),
        radial-gradient(circle at 82% 18%, rgba(99, 169, 255, 0.34) 0, rgba(99, 169, 255, 0) 32%),
        linear-gradient(145deg, #eef4ff 0%, #d8e8fb 42%, #cadcf5 100%);
}

.audit-app-shell {
    width: 100%;
    max-width: var(--mobile-shell-width);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
}

.audit-auth-mode .audit-app-shell {
    display: grid;
    align-items: center;
    padding: 16px;
}

.audit-session-mode .audit-app-shell {
    padding: 16px;
}

.audit-view-frame {
    display: grid;
    align-content: start;
    gap: var(--stack-gap);
}

.zapp-page-stack {
    display: grid;
    align-content: start;
    gap: var(--stack-gap);
}

.zapp-card {
    border: 0;
    border-radius: var(--card-radius);
    box-shadow: var(--zapp-shadow);
    overflow: hidden;
}

.zapp-card > .card-body {
    padding: var(--card-padding);
}

.zapp-hero-card {
    color: #fff;
    background: linear-gradient(160deg, rgba(16, 37, 61, 0.96) 0%, rgba(51, 102, 153, 0.92) 100%);
}

.zapp-hero-card > .card-body {
    display: grid;
    gap: 8px;
}

.zapp-eyebrow {
    margin: 0;
    color: rgba(255, 255, 255, 0.74);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.zapp-hero-copy {
    margin: 0;
    color: rgba(255, 255, 255, 0.84);
    line-height: 1.6;
}

.zapp-context-card {
    border: 1px solid transparent;
    box-shadow: none;
}

.zapp-context-card > .card-body {
    display: grid;
    gap: 10px;
}

.zapp-context-card--primary {
    color: #fff;
    background: linear-gradient(160deg, #336699 0%, #20476d 100%);
    border-color: #336699;
}

.zapp-context-card--info {
    background: #eef8fd;
    border-color: #9ad8f0;
}

.zapp-context-card--success {
    background: #edf9f1;
    border-color: #93d7a7;
}

.zapp-context-card--warning {
    background: #fff7e8;
    border-color: #ffd089;
}

.zapp-context-card--danger {
    background: #fff0f0;
    border-color: #f2a9af;
}

.zapp-context-panel {
    border-left: 6px solid transparent;
}

.zapp-context-panel--primary { border-left-color: var(--zapp-blue); }
.zapp-context-panel--info { border-left-color: #0dcaf0; }
.zapp-context-panel--success { border-left-color: #198754; }
.zapp-context-panel--warning { border-left-color: #ffc107; }
.zapp-context-panel--danger { border-left-color: #dc3545; }

.route-chip,
.zapp-panel-chip {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin: 0;
    padding: 6px 10px;
    border-radius: 999px;
    background: #e8f1fb;
    color: #234b73;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.btn-muted {
    color: var(--zapp-muted-color);
    background: var(--zapp-muted-bg);
    border-color: var(--zapp-muted-border);
}

.btn-muted:hover,
.btn-muted:focus,
.btn-muted:focus-visible,
.btn-muted:active {
    color: #334150;
    background: #dde6f0;
    border-color: #c7d2df;
}

.btn:disabled,
.btn.disabled {
    cursor: not-allowed;
}

.audit-topbar {
    position: sticky;
    top: 12px;
    z-index: 10;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 68px;
    margin-bottom: var(--stack-gap);
    padding: 10px 12px;
    border-radius: 18px;
    color: #fff;
    background: rgba(16, 37, 61, 0.94);
    box-shadow: 0 18px 45px rgba(13, 27, 42, 0.22);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.audit-topbar-button {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 12px;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.audit-topbar-button:hover,
.audit-topbar-button:focus,
.audit-topbar-button:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
}

.audit-brand-mark {
    display: inline-grid;
    width: 46px;
    height: 46px;
    place-items: center;
    padding: 5px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.audit-brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.audit-topbar-copy {
    min-width: 0;
}

.audit-topbar-kicker,
.audit-topbar-title,
.audit-topbar-copy p {
    margin: 0;
}

.audit-topbar-kicker {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.audit-topbar-title {
    overflow: hidden;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audit-topbar-status {
    padding: 6px 9px;
    border-radius: 999px;
    color: #153653;
    background: #e8f1fb;
    font-size: 0.65rem;
    font-weight: 700;
    white-space: nowrap;
}

.audit-auth-page {
    display: grid;
    width: 100%;
    max-width: 580px;
    margin: 0 auto;
    gap: var(--stack-gap);
}

.audit-auth-hero {
    position: relative;
    display: grid;
    gap: 6px;
    padding: 24px 20px 20px;
    overflow: hidden;
    text-align: center;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 18px;
    background:
        radial-gradient(circle at top left, rgba(255, 210, 146, 0.34) 0, rgba(255, 210, 146, 0) 30%),
        radial-gradient(circle at 85% 18%, rgba(118, 193, 255, 0.32) 0, rgba(118, 193, 255, 0) 28%),
        linear-gradient(155deg, rgba(14, 33, 55, 0.94) 0%, rgba(27, 66, 104, 0.9) 58%, rgba(55, 116, 171, 0.86) 100%);
    box-shadow: 0 28px 64px rgba(12, 27, 45, 0.24);
}

.audit-auth-hero::before,
.audit-auth-hero::after {
    position: absolute;
    content: "";
    border-radius: 999px;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.1);
}

.audit-auth-hero::before {
    width: 180px;
    height: 180px;
    top: -88px;
    right: -62px;
}

.audit-auth-hero::after {
    width: 122px;
    height: 122px;
    bottom: -70px;
    left: -34px;
    opacity: 0.8;
}

.audit-auth-kicker,
.audit-auth-title {
    position: relative;
    z-index: 1;
    margin: 0;
}

.audit-auth-kicker {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.audit-auth-title {
    color: #fff;
    font-size: clamp(1.65rem, 7vw, 2.15rem);
    font-weight: 700;
    letter-spacing: -0.04em;
}

.audit-form-card {
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.62);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 24px 60px rgba(28, 52, 84, 0.18);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.audit-form-card::before {
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    content: "";
    background: linear-gradient(90deg, #17314f 0%, #336699 55%, #6fb4ee 100%);
}

.audit-form-card > .card-body {
    padding: 26px 24px 24px;
}

.audit-form-card .form-label,
.audit-field-label {
    margin-bottom: 8px;
    color: rgba(23, 49, 79, 0.7) !important;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.audit-input,
.audit-select {
    min-height: 52px;
    border-color: rgba(23, 49, 79, 0.12);
    border-radius: 10px;
    color: #17314f;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 10px 24px rgba(21, 43, 68, 0.06);
}

.audit-input:focus,
.audit-select:focus {
    border-color: rgba(51, 102, 153, 0.45);
    box-shadow: 0 0 0 0.25rem rgba(51, 102, 153, 0.12), 0 10px 24px rgba(21, 43, 68, 0.08);
}

.audit-primary-action {
    min-height: 50px;
    border: 0;
    border-radius: 16px;
    font-weight: 700;
    background: linear-gradient(135deg, #17314f 0%, #336699 60%, #4d8ac0 100%);
    box-shadow: 0 18px 36px rgba(32, 71, 109, 0.28);
}

.audit-primary-action:hover,
.audit-primary-action:focus,
.audit-primary-action:focus-visible {
    background: linear-gradient(135deg, #16304d 0%, #2e5f8f 60%, #467fb1 100%);
}

.audit-auth-landing {
    display: grid;
    min-height: calc(100dvh - 32px);
    place-items: center;
    text-align: center;
}

.audit-landing-card {
    width: 100%;
    max-width: 520px;
}

.audit-landing-card > .card-body {
    display: grid;
    gap: 14px;
    padding: 28px 24px;
}

.audit-landing-card h1 {
    margin: 0;
    color: var(--zapp-navy);
    font-size: clamp(1.7rem, 8vw, 2.25rem);
}

.audit-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.audit-section-header h2,
.audit-section-header p {
    margin: 0;
}

.audit-section-header h2 {
    color: var(--zapp-navy);
    font-size: 1.1rem;
}

.audit-section-header p,
.audit-helper,
.audit-meta {
    color: #607080;
    font-size: 0.86rem;
    line-height: 1.5;
}

.audit-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.audit-info-cell {
    padding: 12px;
    border-radius: 12px;
    background: rgba(232, 241, 251, 0.7);
}

.audit-info-label,
.audit-metric-label {
    display: block;
    margin-bottom: 4px;
    color: #607080;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.audit-info-value,
.audit-metric-value {
    color: #17314f;
    font-weight: 700;
}

.audit-actions {
    display: grid;
    gap: 10px;
}

.audit-transfer-list,
.audit-item-list {
    display: grid;
    gap: 10px;
}

.audit-transfer-card > .card-body,
.audit-item-card > .card-body {
    display: grid;
    gap: 12px;
    padding: 16px;
}

.audit-transfer-main,
.audit-item-main {
    min-width: 0;
}

.audit-transfer-title,
.audit-item-title {
    margin: 0;
    color: #17314f;
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.audit-transfer-status {
    margin: 0;
    color: #b02a37;
    font-size: 0.8rem;
    font-weight: 700;
}

.audit-size-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.audit-size-cell {
    display: grid;
    min-height: 46px;
    place-items: center;
    padding: 5px 3px;
    border: 1px solid #d8e2ee;
    border-radius: 8px;
    color: #234b73;
    background: #f5f8fc;
    font-size: 0.72rem;
    font-weight: 700;
}

.audit-size-cell strong {
    color: #17314f;
    font-size: 0.9rem;
}

.audit-item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.audit-item-qty {
    color: #17314f;
    font-size: 1.2rem;
    font-weight: 700;
}

.audit-item-actions {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.audit-search-wrap {
    margin-top: 14px;
}

.audit-empty-state {
    padding: 20px 16px;
    border: 1px dashed #b8c8d9;
    border-radius: 12px;
    color: #607080;
    text-align: center;
    background: #f7faff;
}

.audit-sticky-action {
    position: sticky;
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    z-index: 5;
    padding-top: 12px;
    background: linear-gradient(to bottom, rgba(238, 244, 251, 0), #eef4fb 28%);
}

.audit-scanner-page {
    display: grid;
    gap: 14px;
    min-height: 0;
}

.audit-scanner-camera {
    position: relative;
    width: 100%;
    height: clamp(260px, 48dvh, 480px);
    min-height: 260px;
    overflow: hidden;
    border-radius: 14px;
    background: #10253d;
    isolation: isolate;
}

.audit-scanner-camera video,
.audit-scanner-camera canvas {
    position: absolute !important;
    inset: 0;
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none;
    max-height: none;
    object-fit: cover;
}

.audit-scanner-camera video {
    z-index: 1;
}

.audit-scanner-camera canvas {
    z-index: 2;
    pointer-events: none;
}

.audit-scanner-camera br {
    display: none;
}

.audit-scanner-guide {
    position: absolute;
    z-index: 3;
    top: 50%;
    left: 50%;
    width: min(72%, 360px);
    aspect-ratio: 1.8;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, 0.88);
    border-radius: 14px;
    box-shadow: 0 0 0 999px rgba(16, 37, 61, 0.2);
    pointer-events: none;
}

.audit-scanner-camera.scanner-cam--scanned .audit-scanner-guide {
    border-color: #71d39a;
    box-shadow: 0 0 0 999px rgba(25, 135, 84, 0.16);
}

.audit-scanner-code {
    display: block;
    min-height: 28px;
    color: #17314f;
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
}

.audit-size-button {
    display: grid;
    min-height: 58px;
    place-items: center;
    padding: 8px;
    border: 1px solid #93d7a7;
    border-radius: 12px;
    color: #146c43;
    background: #edf9f1;
    font-weight: 700;
}

.audit-size-button:active,
.audit-size-button:focus,
.audit-size-button:hover {
    color: #fff;
    background: #198754;
}

.audit-size-button.haptics {
    color: #fff;
    background: #198754;
    border-color: #146c43;
    transform: scale(0.98);
}

.audit-dialog-sheet {
    display: grid;
    gap: 14px;
    max-height: 90vh;
    max-height: 90dvh;
    padding: 4px;
    overflow: auto;
}

.audit-dialog-sheet h2,
.audit-dialog-sheet h3 {
    margin: 0;
    color: #17314f;
}

.audit-dialog-scroll {
    overflow-x: auto;
}

.audit-dialog-scroll table {
    min-width: 520px;
}

.audit-comparison-list {
    display: grid;
    gap: 12px;
}

.audit-comparison-grid {
    display: grid;
    grid-template-columns: minmax(42px, 0.7fr) repeat(3, minmax(48px, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid #d8e2ee;
    border-radius: 10px;
    background: #d8e2ee;
    font-size: 0.78rem;
    text-align: center;
}

.audit-comparison-grid > div {
    padding: 7px 4px;
    color: #234b73;
    background: #fff;
}

.audit-comparison-grid .audit-comparison-heading {
    color: #5d7389;
    background: #f5f8fc;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.audit-comparison-grid .audit-diff-value {
    color: #b02a37;
    font-weight: 700;
}

.ngdialog.ngdialog-theme-default .ngdialog-content {
    width: min(calc(100vw - 20px), 680px);
    max-height: 92vh;
    max-height: 92dvh;
    margin: 4vh auto;
    padding: 22px;
    overflow: auto;
    border-radius: 18px;
    background: #f7faff;
}

.ngdialog.ngdialog-theme-default .ngdialog-close {
    top: 10px;
    right: 12px;
}

.ngdialog.ngdialog-theme-default.audit-scanner-dialog {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}

.ngdialog.ngdialog-theme-default.audit-scanner-dialog .ngdialog-content {
    display: block;
    width: min(calc(100vw - 32px), 720px);
    height: min(92dvh, 900px);
    max-height: 92dvh;
    min-height: 0;
    margin: 0 auto;
    padding: 22px;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.audit-scanner-dialog .audit-scanner-page {
    width: 100%;
    min-height: 100%;
    height: auto;
    overflow: visible;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.audit-alert-stack .alert {
    margin-bottom: 0;
    border-radius: 12px;
}

@media (min-width: 769px) {
    body.audit-session-mode {
        padding: 24px 16px 40px;
    }

    .audit-app-shell {
        border-radius: 16px;
    }
}

@media (max-width: 430px) {
    .audit-session-mode .audit-app-shell {
        padding: 10px;
    }

    .audit-topbar {
        top: 6px;
        gap: 8px;
        min-height: 60px;
        margin-bottom: 14px;
        padding: 8px 9px;
        border-radius: 16px;
    }

    .audit-topbar-button {
        width: 40px;
        height: 40px;
    }

    .audit-brand-mark {
        width: 40px;
        height: 40px;
    }

    .audit-topbar-title {
        font-size: 0.9rem;
    }

    .audit-topbar-status {
        max-width: 78px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .zapp-card > .card-body {
        padding: 20px;
    }

    .audit-form-card > .card-body {
        padding: 24px 18px 20px;
    }

    .audit-section-header {
        align-items: stretch;
        flex-direction: column;
    }

    .audit-info-grid {
        grid-template-columns: 1fr;
    }

    .audit-item-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .audit-item-actions {
        justify-content: flex-start;
    }

    .ngdialog.ngdialog-theme-default .ngdialog-content {
        width: calc(100vw - 16px);
        margin: 2vh auto;
        padding: 16px;
    }

    .ngdialog.ngdialog-theme-default.audit-scanner-dialog {
        align-items: stretch;
    }

    .ngdialog.ngdialog-theme-default.audit-scanner-dialog .ngdialog-content {
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
        border-radius: 0;
    }

    .audit-scanner-camera {
        height: min(50dvh, 420px);
        min-height: 240px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
