:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #172033;
    background: #f3f6f9;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
}

.shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.card {
    width: min(100%, 42rem);
    padding: clamp(1.5rem, 5vw, 3rem);
    border: 1px solid #dce4ec;
    border-radius: 1.25rem;
    background: #ffffff;
    box-shadow: 0 1rem 3rem rgba(23, 32, 51, 0.08);
}

.eyebrow {
    margin: 0 0 0.5rem;
    color: #52606d;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(2rem, 8vw, 3.5rem);
}

.card > p:not(.eyebrow) {
    margin: 1rem 0 1.5rem;
    color: #52606d;
    line-height: 1.7;
}

.status {
    display: inline-flex;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    color: #0f5132;
    background: #d1e7dd;
    font-size: 0.85rem;
    font-weight: 700;
}

.inventory-page {
    background: #f3f6f9;
}

.inventory-header {
    position: sticky;
    top: 0;
    z-index: 20;
}

.filter-panel,
.stock-table-wrap,
.stock-card,
.empty-state,
.detail-panel {
    border: 1px solid #dce4ec;
    border-radius: 1rem;
    background: #ffffff;
}

.filter-panel,
.empty-state,
.detail-panel {
    padding: 1.25rem;
}

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

.summary-card {
    padding: 1rem;
    border: 1px solid #dce4ec;
    border-radius: 1rem;
    background: #ffffff;
}

.summary-card span {
    display: block;
    color: #52606d;
    font-size: 0.85rem;
}

.summary-card strong {
    display: block;
    margin-top: 0.3rem;
    font-size: 1.55rem;
}

.summary-card-warning {
    border-color: #f1aeb5;
    color: #842029;
    background: #f8d7da;
}

.stock-table-wrap {
    overflow: hidden;
}

.stock-card {
    padding: 1rem;
}

.stock-card-negative {
    border-color: #f1aeb5;
    background: #fff5f5;
}

.stock-value {
    font-size: 1.5rem;
}

.stock-meta > div {
    display: grid;
    grid-template-columns: 5rem minmax(0, 1fr);
    gap: 0.75rem;
}

.stock-meta dt {
    color: #52606d;
    font-size: 0.8rem;
    font-weight: 600;
}

.stock-meta dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

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

.detail-grid > div {
    min-width: 0;
    padding: 0.85rem;
    border-radius: 0.75rem;
    background: #f3f6f9;
}

.detail-grid dt {
    color: #52606d;
    font-size: 0.8rem;
}

.detail-grid dd {
    margin: 0.25rem 0 0;
    overflow-wrap: anywhere;
}

@media (max-width: 991.98px) {
    .inventory-header {
        position: static;
    }

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

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

@media (max-width: 420px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .detail-grid,
    .position-grid {
        grid-template-columns: 1fr;
    }
}

/* AuriInventory application shell */
:root {
    --auri-ink: #102a43;
    --auri-muted: #627d98;
    --auri-line: #d9e2ec;
    --auri-canvas: #f5f7fa;
    --auri-surface: #ffffff;
    --auri-brand: #0f766e;
    --auri-brand-dark: #115e59;
    --auri-brand-soft: #e6fffa;
    --auri-danger: #b42318;
    --auri-warning: #a15c00;
    --auri-radius: 0.9rem;
    --auri-shadow: 0 10px 28px rgba(16, 42, 67, 0.07);
}

.app-body {
    min-height: 100vh;
    color: var(--auri-ink);
    background: var(--auri-canvas);
}

.app-shell {
    width: min(100% - 3rem, 80rem);
    margin-inline: auto;
}

.page-space {
    padding-block: clamp(1.4rem, 3vw, 2.25rem) 3rem;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid rgba(217, 226, 236, 0.86);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(18px);
}

.topbar-inner,
.brand,
.topbar-actions,
.item-card-top,
.hero-meta,
.pagination-bar {
    display: flex;
    align-items: center;
}

.topbar-inner {
    min-height: 4.25rem;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    gap: 0.75rem;
    color: var(--auri-ink);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 2.5rem;
    height: 2.5rem;
    place-items: center;
    border-radius: 0.8rem;
    color: #fff;
    background: var(--auri-brand);
    box-shadow: 0 8px 18px rgba(15, 118, 110, 0.25);
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    letter-spacing: -0.02em;
}

.brand small {
    margin-top: 0.1rem;
    color: var(--auri-muted);
    font-size: 0.72rem;
}

.topbar-actions {
    gap: 0.75rem;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    border-radius: 0.75rem;
    background: #edf2f7;
}

.topbar-nav a {
    padding: 0.48rem 0.72rem;
    border-radius: 0.58rem;
    color: #486581;
    font-size: 0.82rem;
    font-weight: 750;
    text-decoration: none;
}

.topbar-nav a:hover,
.topbar-nav a.active {
    color: var(--auri-brand-dark);
    background: #fff;
    box-shadow: 0 2px 8px rgba(16, 42, 67, 0.08);
}

.quick-filter-grid {
    display: grid;
    grid-template-columns: minmax(13rem, 0.8fr) minmax(18rem, 1.7fr) auto;
    gap: 0.85rem;
    align-items: end;
}

.quick-search-intro {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1.25rem;
}

.quick-search-intro .empty-symbol {
    flex: 0 0 auto;
    margin: 0;
}

.quick-search-intro h2,
.quick-search-intro p {
    margin: 0;
}

.quick-search-intro p {
    margin-top: 0.25rem;
    color: var(--auri-muted);
}

.user-pill,
.warehouse-chip,
.status-badge,
.page-indicator {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 999px;
    white-space: nowrap;
}

.user-pill {
    gap: 0.5rem;
    padding: 0.48rem 0.75rem;
    color: #334e68;
    background: #edf2f7;
    font-size: 0.82rem;
    font-weight: 700;
}

.user-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: #22c55e;
}

.btn-quiet {
    border: 1px solid var(--auri-line);
    color: #334e68;
    background: #fff;
}

.surface {
    border: 1px solid rgba(217, 226, 236, 0.95);
    border-radius: var(--auri-radius);
    background: var(--auri-surface);
    box-shadow: 0 1px 2px rgba(16, 42, 67, 0.03);
}

.page-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1.25rem;
}

.page-hero h1,
.detail-hero h1,
.barcode-hero h1 {
    margin: 0;
    max-width: 24ch;
    font-size: clamp(1.85rem, 3vw, 2.55rem);
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.page-hero > div > p:last-child {
    max-width: 45rem;
    margin: 0.55rem 0 0;
    color: var(--auri-muted);
    font-size: 0.95rem;
}

.freshness-card {
    min-width: 15rem;
    padding: 0.8rem 1rem;
    border-left: 3px solid var(--auri-brand);
    color: var(--auri-muted);
    background: rgba(255, 255, 255, 0.72);
}

.freshness-card span,
.freshness-card strong,
.freshness-card a {
    display: block;
}

.freshness-card span { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
.freshness-card strong { margin: 0.25rem 0 0.5rem; color: var(--auri-ink); font-size: 0.95rem; }
.freshness-card a, .text-link, .back-link, .detail-link { color: var(--auri-brand); font-weight: 750; text-decoration: none; }
.freshness-card a:hover, .text-link:hover, .back-link:hover, .detail-link:hover { color: var(--auri-brand-dark); text-decoration: underline; }

.metric-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.7rem;
    margin-bottom: 1rem;
}

.metric-card,
.weight-card {
    min-width: 0;
    padding: 0.9rem 1rem;
    border: 1px solid var(--auri-line);
    border-radius: var(--auri-radius);
    background: #fff;
}

.metric-card span,
.metric-card small,
.weight-card span,
.weight-card small,
.hero-stat span,
.hero-stat small,
.item-stock-line span,
.item-stock-line small {
    display: block;
}

.metric-card span,
.weight-card span,
.hero-stat span,
.item-stock-line span { color: var(--auri-muted); font-size: 0.78rem; font-weight: 700; }
.metric-card strong { display: block; margin: 0.14rem 0; font-size: 1.55rem; letter-spacing: -0.035em; }
.metric-card small, .weight-card small, .hero-stat small, .item-stock-line small { color: #829ab1; font-size: 0.72rem; }
.metric-primary { border-color: var(--auri-brand); color: #fff; background: var(--auri-brand); box-shadow: 0 12px 30px rgba(15, 118, 110, 0.18); }
.metric-primary span, .metric-primary small { color: rgba(255,255,255,0.76); }
.metric-danger { border-color: #fecdca; color: var(--auri-danger); background: #fff4f2; }

.filter-surface {
    margin-bottom: 1.5rem;
    padding: clamp(1rem, 2vw, 1.25rem);
}

.filter-heading,
.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: end;
}

.filter-heading { margin-bottom: 1.1rem; }
.filter-heading h2, .section-heading h2 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.65rem); letter-spacing: -0.035em; }
.filter-heading p { margin: 0.2rem 0 0; color: var(--auri-muted); }

.filter-grid {
    display: grid;
    grid-template-columns: minmax(15rem, 2fr) minmax(12rem, 1fr) minmax(11rem, 1fr) 7rem 6rem auto;
    gap: 0.75rem;
    align-items: end;
}

.item-filter-grid { grid-template-columns: minmax(15rem, 2fr) minmax(12rem, 1fr) 7rem auto; }
.history-filter-grid { display: grid; grid-template-columns: repeat(2, minmax(10rem, 1fr)) 7rem auto; gap: 0.75rem; align-items: end; }
.field label { display: block; margin-bottom: 0.42rem; color: #486581; font-size: 0.77rem; font-weight: 750; }
.field .form-control, .field .form-select { min-height: 3.25rem; border-color: var(--auri-line); border-radius: 0.82rem; color: var(--auri-ink); font-size: 0.92rem; }
.field .form-control:focus, .field .form-select:focus { border-color: var(--auri-brand); box-shadow: 0 0 0 0.22rem rgba(15, 118, 110, 0.12); }
.btn-brand { min-height: 3.25rem; border-color: var(--auri-brand); border-radius: 0.82rem; color: #fff; background: var(--auri-brand); font-weight: 750; }
.btn-brand:hover, .btn-brand:focus { border-color: var(--auri-brand-dark); color: #fff; background: var(--auri-brand-dark); }
.btn-outline-brand { border-color: #9fb3c8; border-radius: 0.82rem; color: var(--auri-brand-dark); font-weight: 750; }
.btn-outline-brand:hover { border-color: var(--auri-brand); color: #fff; background: var(--auri-brand); }
.filter-note { margin: 0.8rem 0 0; color: var(--auri-muted); font-size: 0.8rem; }

.warehouse-picker { padding: clamp(1.1rem, 3vw, 1.65rem); }
.warehouse-picker-summary {
    display: grid;
    grid-template-columns: minmax(12rem, 1fr) auto auto;
    gap: 1rem;
    align-items: center;
    list-style: none;
    cursor: pointer;
}
.warehouse-picker-summary::-webkit-details-marker { display: none; }
.warehouse-picker-summary > span:first-child strong,
.warehouse-picker-summary > span:first-child small { display: block; }
.warehouse-picker-summary > span:first-child strong { font-size: clamp(1.1rem, 3vw, 1.35rem); letter-spacing: -0.025em; }
.warehouse-picker-summary > span:first-child small { margin-top: 0.2rem; color: var(--auri-muted); }
.warehouse-picker-toggle { white-space: nowrap; }
.warehouse-picker[open] .warehouse-picker-summary { padding-bottom: 1rem; border-bottom: 1px solid var(--auri-line); }
.warehouse-picker-form { padding-top: 1rem; }
.warehouse-picker-help { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.warehouse-picker-help p { margin: 0; color: var(--auri-muted); }
.summary-chips { justify-content: flex-end; margin-top: 0; }
.warehouse-selection-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}
.warehouse-option {
    position: relative;
    display: flex;
    min-height: 4.5rem;
    gap: 0.75rem;
    align-items: center;
    padding: 0.85rem;
    border: 1px solid var(--auri-line);
    border-radius: 0.9rem;
    background: #fff;
    cursor: pointer;
    transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
.warehouse-option:hover { border-color: #9fb3c8; background: #fbfefd; }
.warehouse-option:has(input:focus-visible) { box-shadow: 0 0 0 0.22rem rgba(15, 118, 110, 0.14); }
.warehouse-option:has(input:checked) { border-color: var(--auri-brand); background: var(--auri-brand-soft); }
.warehouse-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.warehouse-option-mark {
    display: grid;
    width: 1.25rem;
    height: 1.25rem;
    flex: 0 0 1.25rem;
    place-items: center;
    border: 2px solid #9fb3c8;
    border-radius: 0.38rem;
    background: #fff;
}
.warehouse-option input:checked + .warehouse-option-mark { border-color: var(--auri-brand); background: var(--auri-brand); }
.warehouse-option input:checked + .warehouse-option-mark::after { content: "✓"; color: #fff; font-size: 0.8rem; font-weight: 900; }
.warehouse-option strong, .warehouse-option small { display: block; overflow-wrap: anywhere; }
.warehouse-option strong { color: var(--auri-ink); font-size: 0.86rem; }
.warehouse-option small { margin-top: 0.2rem; color: var(--auri-muted); font-size: 0.7rem; }
.warehouse-submit { min-width: 12rem; margin-top: 1rem; }
.selection-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.65rem; }
.quick-search-intro { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; padding: 1.25rem; }
.quick-search-intro .empty-symbol { width: 3rem; height: 3rem; flex: 0 0 3rem; margin: 0; font-size: 1.4rem; }
.quick-search-intro h2 { margin: 0; font-size: 1.15rem; }
.quick-search-intro p { margin: 0.25rem 0 0; color: var(--auri-muted); }
.single-value { grid-template-columns: 1fr; }
.simple-detail-hero .mono { margin-top: 0.45rem; color: var(--auri-ink); font-size: clamp(1.45rem, 4vw, 2.5rem); }

.notice {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.15rem;
    border: 1px solid;
    border-radius: 1rem;
}
.notice strong, .notice span { display: block; }
.notice span { margin-top: 0.18rem; font-size: 0.85rem; }
.notice-danger { border-color: #fecdca; color: #7a271a; background: #fff4f2; }
.notice-warning { border-color: #fedf89; color: #7a2e0e; background: #fffaeb; }
.notice-success { border-color: #abefc6; color: #085d3a; background: #ecfdf3; }

.section-heading { margin: 1.65rem 0 0.75rem; }
.section-heading .eyebrow { margin-bottom: 0.25rem; }
.page-indicator { padding: 0.42rem 0.72rem; color: var(--auri-muted); background: #eaf0f5; font-size: 0.78rem; font-weight: 700; }

.data-table-wrap { overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 0.78rem 0.85rem; color: #627d98; background: #f8fafc; font-size: 0.7rem; letter-spacing: 0.045em; text-transform: uppercase; }
.data-table td { padding: 0.88rem 0.85rem; border-top: 1px solid #edf2f7; vertical-align: middle; font-size: 0.85rem; }
.data-table td > strong, .data-table td > span { display: block; }
.data-table tbody tr { transition: background 140ms ease; }
.data-table tbody tr:hover { background: #f8fffe; }
.data-table .row-warning { background: #fff8f7; }
.data-table .row-muted { color: #7b8794; background: #f7f8fa; }
.mono { margin-top: 0.25rem; color: var(--auri-muted); font-family: "Cascadia Mono", Consolas, monospace; font-size: 0.76rem; overflow-wrap: anywhere; }
.warehouse-chip { padding: 0.38rem 0.65rem; color: #334e68; background: #eaf0f5; font-size: 0.73rem; font-weight: 800; }
.stock-number { font-size: 1.18rem; font-variant-numeric: tabular-nums; }
.status-badge { margin: 0.12rem 0; padding: 0.33rem 0.58rem; font-size: 0.68rem; font-weight: 800; }
.status-success { color: #05603a; background: #dcfae6; }
.status-warning { color: #854a0e; background: #fef0c7; }
.status-danger { color: #912018; background: #fee4e2; }
.status-muted { color: #52606d; background: #e4e7eb; }
.detail-link { white-space: nowrap; }

.item-card,
.barcode-card,
.movement-card,
.position-card { padding: 1.1rem; }
.item-card-warning { border-color: #fecdca; background: #fffafa; }
.item-card-top { justify-content: space-between; gap: 0.75rem; color: var(--auri-muted); font-size: 0.75rem; }
.item-card h3, .barcode-card h3, .movement-card h3 { margin: 1rem 0 0; font-size: 1.05rem; }
.item-stock-line { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin: 1rem 0; }
.item-stock-line > div { padding: 0.75rem; border-radius: 0.8rem; background: #f5f7fa; }
.item-stock-line strong { display: inline-block; margin: 0.12rem 0.25rem 0 0; font-size: 1.5rem; }
.item-stock-line small { display: inline-block; }
.item-card-flags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.9rem; }

.pagination-bar { justify-content: space-between; gap: 1rem; margin-top: 1.25rem; }
.pagination-bar > span { display: grid; min-width: 2.2rem; height: 2.2rem; place-items: center; border-radius: 50%; color: #fff; background: var(--auri-ink); font-size: 0.8rem; font-weight: 800; }
.btn-page { border: 1px solid var(--auri-line); border-radius: 0.8rem; color: #334e68; background: #fff; font-weight: 700; }

.empty-state { padding: clamp(2rem, 6vw, 4rem); text-align: center; }
.empty-state h2, .empty-state h3 { margin: 0.8rem 0 0.4rem; }
.empty-state p { margin: 0 auto 1rem; max-width: 34rem; color: var(--auri-muted); }
.empty-symbol { display: grid; width: 3.5rem; height: 3.5rem; margin: 0 auto; place-items: center; border-radius: 1rem; color: var(--auri-brand); background: var(--auri-brand-soft); font-size: 2rem; }

.back-link { display: inline-block; margin-bottom: 1rem; }
.detail-hero, .barcode-hero { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2rem; align-items: center; padding: clamp(1.4rem, 4vw, 2.5rem); overflow: hidden; }
.detail-hero::after, .barcode-hero::after { content: ""; position: absolute; right: -5rem; bottom: -7rem; width: 18rem; height: 18rem; border: 3rem solid rgba(15,118,110,0.06); border-radius: 50%; pointer-events: none; }
.detail-description { max-width: 48rem; margin: 1rem 0 0; color: var(--auri-muted); }
.hero-stat { position: relative; z-index: 1; min-width: 10rem; padding: 1.1rem; border-radius: 1rem; color: #fff; background: var(--auri-ink); text-align: right; }
.hero-stat span, .hero-stat small { color: #bcccdc; }
.hero-stat strong { display: block; margin: 0.15rem 0; font-size: 2.25rem; letter-spacing: -0.05em; }
.hero-status { position: absolute; top: 1.3rem; right: 1.3rem; z-index: 2; }
.position-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.position-total { display: inline-block; margin: 1rem 0.25rem 0 0; font-size: 2rem; letter-spacing: -0.04em; }
.position-breakdown { display: flex; gap: 1rem; margin-top: 0.85rem; padding-top: 0.85rem; border-top: 1px solid var(--auri-line); color: var(--auri-muted); font-size: 0.78rem; }

.barcode-code { display: inline-block; margin: 0.8rem 0; padding: 0.45rem 0.75rem; border: 1px dashed #9fb3c8; border-radius: 0.65rem; color: #334e68; background: #f5f7fa; font-family: "Cascadia Mono", Consolas, monospace; font-weight: 750; }
.hero-meta { flex-wrap: wrap; gap: 0.5rem; color: var(--auri-muted); font-size: 0.78rem; }
.hero-meta span { padding-right: 0.5rem; border-right: 1px solid var(--auri-line); }
.weight-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.85rem; margin-top: 1rem; }
.weight-card strong { display: inline-block; margin: 0.35rem 0.2rem 0 0; font-size: 2rem; letter-spacing: -0.04em; }
.weight-card small { display: inline-block; }
.weight-primary { border-color: var(--auri-brand); color: #fff; background: var(--auri-brand); }
.weight-primary span, .weight-primary small { color: rgba(255,255,255,0.74); }
.spec-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; padding: 0; overflow: hidden; }
.spec-grid > div { padding: 1rem; border-right: 1px solid var(--auri-line); border-bottom: 1px solid var(--auri-line); }
.spec-grid dt { color: var(--auri-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.spec-grid dd { margin: 0.25rem 0 0; overflow-wrap: anywhere; font-weight: 650; }
.movement-values { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; margin-top: 1rem; }
.movement-values span { padding: 0.7rem; border-radius: 0.7rem; background: #f5f7fa; }
.movement-values b { display: block; margin-top: 0.15rem; }
.number-positive { color: #067647; font-weight: 750; }
.number-negative { color: #b42318; font-weight: 750; }

@media (max-width: 1199.98px) {
    .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .filter-submit { width: 100%; }
    .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 991.98px) {
    .topbar { position: static; }
    .page-hero { grid-template-columns: 1fr; align-items: start; }
    .freshness-card { min-width: 0; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-grid, .item-filter-grid, .history-filter-grid, .quick-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .quick-filter-grid .filter-submit { grid-column: 1 / -1; }
    .field-search { grid-column: 1 / -1; }
    .position-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .weight-grid, .spec-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .warehouse-selection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 575.98px) {
    .app-shell { width: min(100% - 1rem, 80rem); }
    .topbar-inner { min-height: 4.25rem; padding-block: 0.5rem; flex-wrap: wrap; }
    .brand small, .user-pill { display: none; }
    .topbar-nav { order: 3; width: 100%; }
    .topbar-nav a { flex: 1; text-align: center; }
    .page-space { padding-top: 1.25rem; }
    .page-hero { gap: 1rem; margin-bottom: 1.25rem; }
    .page-hero h1, .detail-hero h1, .barcode-hero h1 { font-size: 1.85rem; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
    .metric-card { padding: 0.9rem; }
    .metric-card strong { font-size: 1.5rem; }
    .metric-card:last-child { grid-column: 1 / -1; }
    .filter-heading, .section-heading { align-items: start; flex-wrap: wrap; }
    .filter-heading > div, .section-heading > div { min-width: 0; }
    .filter-grid, .item-filter-grid, .history-filter-grid, .quick-filter-grid, .position-grid, .weight-grid, .spec-grid, .warehouse-selection-grid { grid-template-columns: 1fr; }
    .field-search { grid-column: auto; }
    .filter-submit { min-height: 3.25rem; }
    .detail-hero, .barcode-hero { grid-template-columns: 1fr; padding-top: 3.2rem; }
    .hero-stat { text-align: left; }
    .hero-status { top: 1rem; right: 1rem; }
    .page-indicator { white-space: normal; text-align: left; }
    .pagination-bar .btn { padding-inline: 0.7rem; font-size: 0.78rem; }
    .warehouse-submit { width: 100%; }
    .warehouse-picker-summary { grid-template-columns: minmax(0, 1fr) auto; }
    .summary-chips { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
    .warehouse-picker-help { align-items: flex-start; flex-direction: column; }
    .quick-search-intro { align-items: flex-start; }
}

/* Mobile-first stock hierarchy */
.hierarchy-body { padding-bottom: 6.25rem; }
.hierarchy-page { width: min(100% - 1rem, 58rem); padding-block: 1.25rem 2rem; }
.hierarchy-heading { margin-bottom: 1rem; padding: 0.35rem 0.25rem; }
.hierarchy-heading h1, .result-caption h1, .history-heading h1 { margin: 0; font-size: clamp(1.6rem, 5vw, 2.25rem); letter-spacing: -0.04em; }
.hierarchy-heading > p:last-child, .history-heading p { margin: 0.4rem 0 0; color: var(--auri-muted); }
.hierarchy-filter { display: grid; gap: 0.75rem; padding: 0.85rem; }
.multi-picker { border: 1px solid var(--auri-line); border-radius: 0.8rem; background: #fff; overflow: hidden; }
.multi-picker summary { display: flex; min-height: 4.25rem; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.75rem 0.9rem; list-style: none; cursor: pointer; }
.multi-picker summary::-webkit-details-marker { display: none; }
.multi-picker summary small, .multi-picker summary strong { display: block; }
.multi-picker summary small { color: var(--auri-muted); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.multi-picker summary strong { margin-top: 0.15rem; color: var(--auri-ink); }
.picker-chevron { color: var(--auri-brand); font-size: 1.4rem; transition: transform 140ms ease; }
.multi-picker[open] .picker-chevron { transform: rotate(180deg); }
.multi-picker fieldset { display: grid; max-height: 17rem; gap: 0.45rem; margin: 0; padding: 0.7rem; border: 0; border-top: 1px solid var(--auri-line); overflow-y: auto; }
.compact-option { position: relative; display: flex; min-height: 2.85rem; align-items: center; gap: 0.65rem; padding: 0.55rem 0.7rem; border-radius: 0.65rem; cursor: pointer; }
.compact-option:hover, .compact-option:has(input:checked) { background: var(--auri-brand-soft); }
.compact-option input { position: absolute; opacity: 0; }
.compact-option > span { display: grid; width: 1.15rem; height: 1.15rem; place-items: center; border: 2px solid #9fb3c8; border-radius: 0.34rem; background: #fff; }
.compact-option input:checked + span { border-color: var(--auri-brand); background: var(--auri-brand); }
.compact-option input:checked + span::after { content: "✓"; color: #fff; font-size: 0.72rem; font-weight: 900; }
.compact-option b { overflow-wrap: anywhere; font-size: 0.85rem; }
.selection-required-message { display: none; margin: 0; color: var(--auri-warning); font-size: 0.78rem; }
.selection-required-message.visible { display: block; }
.hierarchy-submit { width: 100%; }
.hierarchy-submit:disabled { border-color: #9fb3c8; background: #9fb3c8; }
.hierarchy-empty { margin-top: 1rem; padding: clamp(1.5rem, 7vw, 3rem); text-align: center; }
.hierarchy-empty h2, .hierarchy-empty h3 { margin: 0.75rem 0 0.35rem; }
.hierarchy-empty p { margin: 0; color: var(--auri-muted); }
.hierarchy-results { margin-top: 1.15rem; }
.detail-level { margin-top: 0; }
.result-caption { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 0.65rem; padding-inline: 0.2rem; }
.result-caption h2 { margin: 0; font-size: 1.3rem; letter-spacing: -0.035em; }
.result-caption > span { flex: 0 0 auto; padding: 0.35rem 0.6rem; border-radius: 999px; color: var(--auri-muted); background: #eaf0f5; font-size: 0.72rem; font-weight: 750; }
.title-centered { align-items: center; }
.drill-panel { padding-inline: 1rem; overflow: hidden; }
.drill-row { display: grid; min-height: 4.15rem; grid-template-columns: minmax(0, 1fr) auto 1rem; align-items: center; gap: 0.75rem; padding: 0.75rem 0.2rem; border-bottom: 1px solid var(--auri-line); color: var(--auri-ink); text-decoration: none; }
.drill-row:last-child { border-bottom: 0; }
.drill-row:hover, .drill-row:focus-visible { color: var(--auri-brand-dark); background: #f8fffe; }
.drill-row > span { min-width: 0; overflow-wrap: anywhere; font-weight: 700; }
.drill-row > strong { font-size: 1rem; font-variant-numeric: tabular-nums; }
.drill-row > i { color: #9fb3c8; font-size: 1.6rem; font-style: normal; }
.mono-strong, .mono-title { font-family: "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }
.hierarchy-back { display: grid; width: 2.6rem; height: 2.6rem; margin-bottom: 0.7rem; place-items: center; border: 1px solid var(--auri-line); border-radius: 50%; color: var(--auri-ink); background: #fff; text-decoration: none; font-size: 1.2rem; }
.hierarchy-back:hover { color: #fff; background: var(--auri-brand); }
.app-bottom-nav { position: fixed; z-index: 50; right: 0; bottom: 0; left: 0; padding: 0.45rem max(0.5rem, env(safe-area-inset-right)) max(0.45rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--auri-line); background: rgba(255,255,255,0.96); backdrop-filter: blur(16px); }
.bottom-nav-inner { display: grid; width: min(100%, 34rem); grid-template-columns: repeat(3, 1fr); margin-inline: auto; }
.bottom-nav-inner a { display: grid; min-height: 4.2rem; place-items: center; align-content: center; gap: 0.15rem; border-right: 1px solid var(--auri-line); color: var(--auri-muted); text-decoration: none; font-size: 0.7rem; font-weight: 750; }
.bottom-nav-inner a:last-child { border-right: 0; }
.bottom-nav-inner a.active { color: var(--auri-brand-dark); }
.bottom-nav-inner svg { width: 1.45rem; height: 1.45rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.history-heading { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 1rem; align-items: center; padding: 1.15rem; }
.history-current { min-width: 7rem; padding: 0.8rem; border-radius: 0.8rem; color: #fff; background: var(--auri-ink); text-align: right; }
.history-current span, .history-current strong { display: block; }
.history-current span { color: #bcccdc; font-size: 0.7rem; }
.history-current strong { font-size: 1.6rem; }
.history-list { display: grid; gap: 0.6rem; }
.history-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 1rem; padding: 0.9rem; }
.history-row strong, .history-row span { display: block; }
.history-row span { margin-top: 0.2rem; color: var(--auri-muted); font-size: 0.72rem; }
.history-row p { margin: 0.35rem 0 0; color: #486581; font-size: 0.82rem; }
.history-values { display: flex; gap: 0.55rem; align-items: center; text-align: right; }
.history-values span { min-width: 3rem; margin: 0; font-size: 0.8rem; }
.history-values b { display: inline; }

@media (min-width: 768px) {
    .hierarchy-page { padding-top: 2rem; }
    .hierarchy-filter { grid-template-columns: repeat(2, minmax(0,1fr)) auto; align-items: start; padding: 1rem; }
    .hierarchy-filter .selection-required-message { grid-column: 1 / 3; }
    .hierarchy-submit { width: auto; min-width: 10rem; }
    .drill-panel { padding-inline: 1.25rem; }
    .drill-row { padding-inline: 0.5rem; }
}

@media (max-width: 575.98px) {
    .compact-topbar .topbar-inner { flex-wrap: nowrap; }
    .history-heading { grid-template-columns: 1fr; }
    .history-current { text-align: left; }
}

.login-body {
    min-height: 100vh;
    color: var(--auri-ink);
    background: #fff;
}

.login-stage {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(0, 0.9fr) minmax(25rem, 1.1fr);
}

.login-story {
    display: flex;
    min-height: 100%;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(2rem, 5vw, 4rem);
    color: #fff;
    background:
        radial-gradient(circle at 85% 20%, rgba(45, 212, 191, 0.28), transparent 24rem),
        var(--auri-ink);
}

.login-story .brand { color: #fff; }
.login-story .brand small { color: #9fb3c8; }
.login-story .eyebrow { color: #5eead4; }
.login-story h1 { max-width: 14ch; font-size: clamp(2.4rem, 4.5vw, 4.1rem); line-height: 1; letter-spacing: -0.055em; }
.login-story > div > p:last-child { max-width: 40rem; margin: 1.5rem 0 0; color: #bcccdc; font-size: 1.08rem; line-height: 1.7; }
.login-points { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; padding-top: 2rem; border-top: 1px solid rgba(255,255,255,0.14); }
.login-points span { color: #bcccdc; font-size: 0.78rem; }
.login-points b { display: block; margin-bottom: 0.4rem; color: #5eead4; font-size: 0.72rem; }

.login-panel { display: grid; place-items: center; padding: clamp(1.5rem, 6vw, 5rem); background: #fff; }
.login-form-wrap { width: min(100%, 28rem); }
.login-form-wrap h2 { margin: 0; font-size: clamp(1.9rem, 4vw, 2.7rem); letter-spacing: -0.05em; }
.login-copy { margin: 0.6rem 0 1.5rem; color: var(--auri-muted); }
.login-form { display: grid; gap: 1rem; }
.login-form .btn { margin-top: 0.25rem; }
.login-footnote { display: flex; gap: 0.5rem; align-items: center; margin: 1.25rem 0 0; color: var(--auri-muted); font-size: 0.78rem; }

@media (max-width: 899.98px) {
    .login-stage { grid-template-columns: 1fr; }
    .login-story { min-height: auto; gap: 3rem; padding-bottom: 2rem; }
    .login-story h1 { max-width: 16ch; font-size: clamp(2.4rem, 10vw, 4rem); }
    .login-panel { min-height: 32rem; }
}

@media (max-width: 575.98px) {
    .login-story { padding: 1.35rem; }
    .login-story > div > p:last-child { font-size: 0.95rem; }
    .login-points { grid-template-columns: 1fr; gap: 0.65rem; }
    .login-points span { display: flex; gap: 0.55rem; align-items: center; }
    .login-points b { margin: 0; }
    .login-panel { min-height: auto; padding: 2rem 1.25rem 3rem; }
}
