:root {
    --phx-bg: #f3ebdf;
    --phx-surface: rgba(255, 250, 242, 0.9);
    --phx-surface-strong: #fffaf4;
    --phx-ink: #1f2a37;
    --phx-muted: #6b7280;
    --phx-accent: #d1643d;
    --phx-accent-deep: #a94724;
    --phx-outline: rgba(31, 42, 55, 0.12);
    --phx-success: #1f6b42;
    --phx-danger: #9b2c2c;
    --phx-shadow: 0 24px 48px rgba(31, 42, 55, 0.12);
    --phx-radius: 1.5rem;
}

body.warehouse-body,
body.login-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(209, 100, 61, 0.22), transparent 26%),
        linear-gradient(180deg, #faf4ec 0%, #eee0cd 100%);
    color: var(--phx-ink);
}

a {
    text-decoration: none;
}

.app-shell {
    padding-top: 1rem;
    padding-bottom: 3rem;
}

.topbar {
    margin-bottom: 1rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.9rem;
    color: var(--phx-ink);
}

.brand strong,
h1,
h2 {
    letter-spacing: -0.03em;
}

.brand small,
.eyebrow,
.search-status,
.lookup-status,
.meta-list dt,
.component-card-meta,
.timeline time {
    color: var(--phx-muted);
}

.brand-mark {
    display: inline-flex;
    width: 3rem;
    height: 3rem;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    background: var(--phx-ink);
    color: #fff;
    font-weight: 700;
}

.topnav .nav-link,
.link-button {
    color: var(--phx-muted);
    font-weight: 600;
    background: transparent;
    border: 0;
}

.topnav .nav-link:hover,
.topnav .nav-link:focus,
.text-link:hover {
    color: var(--phx-accent-deep);
}

.hero,
.panel,
.detail-copy,
.detail-media,
.login-card {
    background: var(--phx-surface);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: var(--phx-radius);
    box-shadow: var(--phx-shadow);
    backdrop-filter: blur(12px);
}

.hero,
.panel,
.detail-copy,
.detail-media,
.login-card {
    padding: 1.5rem;
}

.hero h1,
.detail-copy h1 {
    font-size: clamp(2rem, 3vw, 3.3rem);
    margin: 0.15rem 0;
}

.hero-copy {
    max-width: 52rem;
    font-size: 1.05rem;
    line-height: 1.6;
}

.eyebrow,
.group-title,
.search-field span {
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    font-weight: 800;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.panel-head h2 {
    margin: 0.15rem 0 0;
}

.hero-actions,
.action-stack,
.stack,
.timeline,
.message-stack,
.result-list,
.meta-list {
    display: grid;
    gap: 0.9rem;
}

.btn {
    border-radius: 1rem;
    font-weight: 700;
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
}

.btn-primary {
    --bs-btn-bg: var(--phx-accent);
    --bs-btn-border-color: var(--phx-accent);
    --bs-btn-hover-bg: var(--phx-accent-deep);
    --bs-btn-hover-border-color: var(--phx-accent-deep);
    --bs-btn-active-bg: var(--phx-accent-deep);
    --bs-btn-active-border-color: var(--phx-accent-deep);
}

.input-group-text,
.form-control,
.form-select {
    border-radius: 1rem;
    border-color: var(--phx-outline);
}

.input-group > .form-control,
.input-group > .form-select {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group > .input-group-text {
    background: #fff;
    color: var(--phx-muted);
}

.form-control:focus,
.form-select:focus,
.btn:focus,
.link-button:focus {
    border-color: rgba(209, 100, 61, 0.4);
    box-shadow: 0 0 0 0.25rem rgba(209, 100, 61, 0.15);
}

.search-results {
    min-height: 4rem;
}

.search-results .group-title {
    margin-bottom: 0.45rem;
}

.search-results .search-groups {
    display: grid;
    gap: 0.85rem;
}

.search-results .result-list {
    gap: 0.45rem;
}

.component-card,
.timeline-item,
.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 1.1rem;
    border: 1px solid var(--phx-outline);
    background: var(--phx-surface-strong);
    color: var(--phx-ink);
}

.flash-progress-wrap {
    height: 1rem;
    background: rgba(31, 42, 55, 0.08);
}

.flash-log {
    min-height: 16rem;
    max-height: 24rem;
    overflow: auto;
    padding: 1rem;
    border-radius: 1rem;
    background: #15202b;
    color: #d9f6e6;
    font-size: 0.88rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.component-card p,
.timeline-item p,
.result-row-copy p,
.empty {
    margin: 0.2rem 0 0;
    color: var(--phx-muted);
}

.component-card-meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.92rem;
}

.dashboard-recent-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.dashboard-recent-card {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 0.65rem;
    align-items: center;
    padding: 0.7rem;
    border-radius: 1rem;
    border: 1px solid var(--phx-outline);
    background: var(--phx-surface-strong);
    color: var(--phx-ink);
    min-width: 0;
}

.dashboard-recent-image img,
.dashboard-recent-image .image-placeholder {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 0.8rem;
    background: rgba(31, 42, 55, 0.08);
}

.dashboard-recent-body {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
}

.dashboard-recent-title {
    font-size: 0.85rem;
    line-height: 1.2;
    word-break: break-word;
}

.dashboard-recent-qty {
    color: var(--phx-muted);
    font-size: 0.78rem;
    white-space: nowrap;
}

.dashboard-history-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.dashboard-history-card {
    display: grid;
    gap: 0.35rem;
    padding: 0.75rem;
    border-radius: 1rem;
    border: 1px solid var(--phx-outline);
    background: var(--phx-surface-strong);
}

.dashboard-history-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.dashboard-history-title {
    font-size: 0.84rem;
    line-height: 1.2;
    word-break: break-word;
}

.dashboard-history-time {
    color: var(--phx-muted);
    font-size: 0.72rem;
    white-space: nowrap;
}

.dashboard-history-message {
    margin: 0;
    color: var(--phx-muted);
    font-size: 0.76rem;
    line-height: 1.3;
}

.component-tile-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.85rem;
}

.component-tile {
    display: grid;
    gap: 0.55rem;
    padding: 0.65rem;
    border-radius: 1rem;
    border: 1px solid var(--phx-outline);
    background: var(--phx-surface-strong);
    color: var(--phx-ink);
    min-width: 0;
}

.component-tile-image img,
.component-tile-image .image-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 0.8rem;
    background: rgba(31, 42, 55, 0.08);
}

.image-placeholder.compact {
    font-size: 0.72rem;
    padding: 0.5rem;
    text-align: center;
}

.component-tile-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
}

.component-tile-title {
    display: block;
    font-size: 0.84rem;
    line-height: 1.2;
    margin-bottom: 0.2rem;
    word-break: break-word;
}

.component-tile-description {
    margin: 0;
    color: var(--phx-muted);
    font-size: 0.72rem;
    line-height: 1.25;
    min-height: 2.25em;
}

.component-tile-meta {
    display: grid;
    gap: 0.35rem;
    margin-top: auto;
    padding-top: 0.45rem;
    color: var(--phx-muted);
    font-size: 0.72rem;
    min-width: 0;
}

.component-tile-stockline {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex-wrap: nowrap;
}

.component-tile-stockline span {
    display: inline-block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.component-tile-stockline span:first-child {
    flex: 0 0 auto;
}

.component-tile-stockline span:last-child {
    flex: 1 1 auto;
}

.component-tile-category-row {
    display: flex;
    justify-content: flex-start;
    min-width: 0;
}

.component-tile-category {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.42rem;
    border-radius: 999px;
    background: rgba(31, 42, 55, 0.08);
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: fit-content;
}

.message {
    padding: 0.95rem 1rem;
    border-radius: 1rem;
    font-weight: 700;
    background: rgba(31, 42, 55, 0.08);
}

.message-success {
    background: rgba(31, 107, 66, 0.14);
    color: var(--phx-success);
}

.message-error {
    background: rgba(155, 44, 44, 0.12);
    color: var(--phx-danger);
}

.detail-copy,
.detail-media {
    height: 100%;
}

.detail-media img,
.image-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 1.1rem;
    background: rgba(31, 42, 55, 0.08);
}

.image-placeholder {
    display: grid;
    place-items: center;
    font-weight: 700;
}

.detail-media-upload {
    position: relative;
}

.detail-media-form {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
}

.detail-media-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border: 0;
    border-radius: 999px;
    background: rgba(31, 42, 55, 0.86);
    color: #fff;
    box-shadow: 0 10px 20px rgba(31, 42, 55, 0.18);
    font-size: 1.35rem;
}

.detail-media-edit:hover,
.detail-media-edit:focus {
    background: var(--phx-accent-deep);
}

.meta-row {
    gap: 0.75rem;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.65rem 0.9rem;
    border-radius: 999px;
    background: rgba(31, 42, 55, 0.08);
    font-weight: 700;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.delta-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
    margin: 1rem 0;
}

.delta-button {
    border: 1px solid var(--phx-outline);
    background: #fff;
    border-radius: 1rem;
    padding: 1rem;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
}

.delta-button.is-selected {
    outline: 3px solid rgba(209, 100, 61, 0.25);
    border-color: var(--phx-accent);
}

.delta-button.is-positive {
    color: var(--phx-success);
}

.delta-button.is-negative {
    color: var(--phx-danger);
}

.booking-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.95rem 1rem;
    border-radius: 1rem;
    background: rgba(31, 42, 55, 0.06);
    margin-bottom: 1rem;
}

.meta-list div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--phx-outline);
}

.scanner-video {
    width: 100%;
    min-height: 320px;
    object-fit: cover;
    border-radius: 1.1rem;
    background: #0d1325;
}

.scanner-stage {
    position: relative;
    overflow: hidden;
    border-radius: 1.1rem;
}

.scanner-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
}

.scanner-frame {
    position: relative;
    width: min(82%, 420px);
    aspect-ratio: 1.5 / 1;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 1.2rem;
    box-shadow: 0 0 0 9999px rgba(13, 19, 37, 0.28);
    overflow: hidden;
}

.scanner-frame::before,
.scanner-frame::after {
    content: "";
    position: absolute;
    left: 1rem;
    right: 1rem;
    height: 1px;
    background: rgba(255, 255, 255, 0.22);
}

.scanner-frame::before {
    top: 24%;
}

.scanner-frame::after {
    bottom: 24%;
}

.scanner-frame-line {
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    top: 50%;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(255, 79, 79, 0.25), #ff4f4f, rgba(255, 79, 79, 0.25));
    box-shadow: 0 0 18px rgba(255, 79, 79, 0.75);
    transform: translateY(-50%);
}

.scanner-overlay-caption {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    background: rgba(13, 19, 37, 0.68);
    color: white;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.result-row img {
    width: 64px;
    height: 64px;
    border-radius: 1rem;
    object-fit: cover;
    background: rgba(31, 42, 55, 0.08);
}

.search-results .result-row {
    gap: 0.75rem;
    padding: 0.65rem 0.8rem;
    border-radius: 0.9rem;
}

.search-results .result-row img,
.search-results .result-row .image-placeholder {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 0.8rem;
}

.search-results .result-row .image-placeholder {
    font-size: 0.72rem;
}

.search-results .result-row-copy strong {
    display: block;
    font-size: 0.95rem;
    line-height: 1.15;
}

.search-results .result-row-copy p {
    margin-top: 0.1rem;
    font-size: 0.82rem;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-results .result-row-meta {
    font-size: 0.8rem;
    line-height: 1.2;
    min-width: 5.5rem;
}

.search-results .search-empty {
    padding: 0.65rem 0.8rem;
    font-size: 0.85rem;
}

.result-row-copy {
    flex: 1;
    min-width: 0;
}

.result-row-meta {
    text-align: right;
    font-size: 0.9rem;
    color: var(--phx-muted);
}

.result-row.is-active {
    border-color: var(--phx-accent);
    box-shadow: 0 0 0 0.25rem rgba(209, 100, 61, 0.12);
}

.search-empty {
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    background: rgba(31, 42, 55, 0.04);
    color: var(--phx-muted);
}

.login-body {
    display: grid;
    place-items: center;
}

.login-card {
    width: min(28rem, calc(100% - 2rem));
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-left: 0;
}

.form-check .form-check-input {
    margin-left: 0;
    margin-top: 0;
    float: none;
}

@media (max-width: 991.98px) {
    .topnav {
        padding-top: 0.75rem;
    }

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

    .dashboard-history-grid {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 767.98px) {
    .app-shell {
        padding-bottom: 2rem;
    }

    .hero,
    .panel,
    .detail-copy,
    .detail-media,
    .login-card {
        padding: 1rem;
        border-radius: 1.25rem;
    }

    .panel-head,
    .timeline-item,
    .result-row,
    .component-card,
    .component-card-meta {
        flex-direction: column;
        align-items: stretch;
    }

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

    .result-row-meta {
        text-align: left;
    }

    .dashboard-recent-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.6rem;
    }

    .dashboard-recent-card {
        grid-template-columns: 48px minmax(0, 1fr);
        padding: 0.55rem;
    }

    .dashboard-recent-image img,
    .dashboard-recent-image .image-placeholder {
        width: 48px;
        height: 48px;
    }

    .dashboard-history-grid {
        gap: 0.6rem;
    }

    .dashboard-history-card {
        padding: 0.6rem;
    }

    .component-tile-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.65rem;
    }

    .component-tile {
        padding: 0.5rem;
    }
}
