:root {
    --bg: #e8dcc7;
    --bg-soft: #f5eddc;
    --surface: #fffaf0;
    --surface-strong: #f0dfbf;
    --primary: #174332;
    --primary-2: #2d654a;
    --accent: #c08e3a;
    --accent-2: #c66b3d;
    --danger: #b42318;
    --danger-bg: #ffe1dc;
    --warning: #a35c00;
    --warning-bg: #fff1c2;
    --ok: #276749;
    --text: #1f271f;
    --muted: #6d6a5f;
    --line: rgba(31, 39, 31, .12);
    --shadow: 0 18px 45px rgba(43, 37, 22, .14);
    --radius-lg: 26px;
    --radius-md: 18px;
    --radius-sm: 12px;
    --nav-height: 78px;
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 10% 0%, rgba(192, 142, 58, .2), transparent 32rem),
        linear-gradient(135deg, var(--bg) 0%, #d4b895 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .12;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    position: relative;
    width: min(100%, 560px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 18px 16px calc(var(--nav-height) + 28px);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: -18px -16px 12px;
    padding: calc(18px + env(safe-area-inset-top)) 16px 14px;
    background: linear-gradient(180deg, rgba(232, 220, 199, .96), rgba(232, 220, 199, .74));
    backdrop-filter: blur(18px);
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: clamp(2rem, 11vw, 3.8rem);
    line-height: .92;
    letter-spacing: 0;
    color: var(--primary);
}

h2 {
    font-size: 1.45rem;
    line-height: 1.05;
    color: var(--primary);
}

h3 {
    font-size: 1rem;
    line-height: 1.2;
}

.overline {
    margin-bottom: 5px;
    color: var(--accent-2);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
}

.app-main {
    display: grid;
    gap: 16px;
}

.screen {
    display: grid;
    gap: 16px;
    animation: rise .22s ease-out;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

.hero-panel,
.section-panel,
.product-card,
.location-card,
.shopping-row,
.alert-card,
.install-card {
    border: 1px solid rgba(255, 250, 240, .6);
    background: rgba(255, 250, 240, .82);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.hero-panel {
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 18px;
    padding: 22px;
    border-radius: 32px;
    color: #fffaf0;
    background:
        linear-gradient(135deg, rgba(23, 67, 50, .98), rgba(45, 101, 74, .94)),
        var(--primary);
}

.hero-panel::after {
    content: "";
    position: absolute;
    right: -46px;
    bottom: -42px;
    width: 170px;
    height: 170px;
    border-radius: 999px;
    border: 28px solid rgba(192, 142, 58, .28);
}

.hero-panel h2 {
    max-width: 10ch;
    color: inherit;
    font-size: 2.35rem;
}

.hero-panel p {
    max-width: 27ch;
    color: rgba(255, 250, 240, .78);
}

.hero-actions,
.quick-grid,
.stats-grid,
.chip-row,
.sheet-actions,
.two-col {
    display: grid;
    gap: 10px;
}

.hero-actions {
    grid-template-columns: 1fr 1fr;
}

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

.stat-card {
    min-height: 108px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255, 250, 240, .72);
}

.stat-card strong {
    display: block;
    margin-top: 10px;
    color: var(--primary);
    font-size: 2rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: .88rem;
    font-weight: 700;
}

.stat-card i,
.icon-badge i {
    width: 22px;
    height: 22px;
}

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

.section-panel {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius-lg);
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-title small {
    color: var(--muted);
    font-weight: 800;
}

.product-list,
.shopping-list,
.alert-list,
.location-grid,
.category-bars {
    display: grid;
    gap: 12px;
}

.product-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
    border-radius: 22px;
}

.product-main {
    display: grid;
    min-width: 0;
    gap: 9px;
}

.product-head,
.product-meta,
.card-actions,
.mini-actions,
.shopping-row,
.filter-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-head {
    justify-content: space-between;
}

.product-head h3 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-meta {
    flex-wrap: wrap;
    color: var(--muted);
    font-size: .84rem;
    font-weight: 650;
}

.card-actions {
    flex-wrap: wrap;
}

.icon-badge {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    border-radius: 18px;
    color: var(--primary);
    background: var(--surface-strong);
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 850;
}

.status.ok {
    color: var(--ok);
    background: rgba(39, 103, 73, .12);
}

.status.warning {
    color: var(--warning);
    background: var(--warning-bg);
}

.status.danger {
    color: var(--danger);
    background: var(--danger-bg);
}

.button,
.icon-button,
.nav-item,
.chip,
.fab {
    border: 0;
    border-radius: 999px;
    transition: transform .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 15px;
    font-weight: 850;
    text-decoration: none;
}

.button i,
.chip i {
    width: 18px;
    height: 18px;
}

.button.primary {
    color: #fffaf0;
    background: var(--primary);
    box-shadow: 0 10px 24px rgba(23, 67, 50, .25);
}

.button.secondary {
    color: var(--primary);
    background: var(--surface-strong);
}

.button.ghost {
    color: var(--primary);
    background: rgba(23, 67, 50, .08);
}

.button.danger {
    color: var(--danger);
    background: var(--danger-bg);
}

.button.small {
    min-height: 34px;
    padding: 7px 11px;
    font-size: .84rem;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    color: var(--primary);
    background: rgba(255, 250, 240, .78);
}

.icon-button i {
    width: 20px;
    height: 20px;
}

.fab {
    position: fixed;
    right: max(18px, calc((100vw - 560px) / 2 + 18px));
    bottom: calc(var(--nav-height) + 20px + env(safe-area-inset-bottom));
    z-index: 20;
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    color: #fffaf0;
    background: var(--accent-2);
    box-shadow: 0 18px 34px rgba(198, 107, 61, .42);
}

.fab i {
    width: 28px;
    height: 28px;
}

.button:active,
.icon-button:active,
.nav-item:active,
.chip:active,
.fab:active {
    transform: translateY(1px) scale(.98);
}

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 0;
    z-index: 18;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: min(100%, 560px);
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 250, 240, .7);
    background: rgba(255, 250, 240, .9);
    box-shadow: 0 -14px 36px rgba(43, 37, 22, .12);
    transform: translateX(-50%);
    backdrop-filter: blur(18px);
}

.nav-item {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    color: var(--muted);
    background: transparent;
    font-size: .72rem;
    font-weight: 800;
}

.nav-item i {
    width: 21px;
    height: 21px;
}

.nav-item.active {
    color: #fffaf0;
    background: var(--primary);
}

.toolbar {
    display: grid;
    gap: 10px;
}

.search-box,
.select-line select,
.toolbar > select,
label input,
label select,
label textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: rgba(255, 250, 240, .9);
    outline: none;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
}

.search-box input {
    min-height: 46px;
    border: 0;
    background: transparent;
    outline: none;
}

.filter-line {
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.filter-line::-webkit-scrollbar {
    display: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    flex: 0 0 auto;
    padding: 8px 12px;
    color: var(--primary);
    background: rgba(255, 250, 240, .68);
    font-size: .86rem;
    font-weight: 850;
}

.chip.active {
    color: #fffaf0;
    background: var(--primary);
}

.select-line {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--primary);
    font-size: .82rem;
    font-weight: 850;
}

label input,
label select,
label textarea {
    min-height: 46px;
    padding: 11px 12px;
}

label textarea {
    resize: vertical;
}

.two-col {
    grid-template-columns: 1fr 1fr;
}

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(31, 39, 31, .42);
    backdrop-filter: blur(4px);
}

.bottom-sheet {
    position: fixed;
    left: 50%;
    bottom: 0;
    z-index: 31;
    width: min(100%, 560px);
    max-height: 88vh;
    padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
    border-radius: 30px 30px 0 0;
    background: var(--bg-soft);
    box-shadow: 0 -24px 70px rgba(31, 39, 31, .24);
    overflow-y: auto;
    transform: translateX(-50%);
}

.sheet-handle {
    width: 48px;
    height: 5px;
    margin: 0 auto 14px;
    border-radius: 999px;
    background: rgba(31, 39, 31, .22);
}

.sheet-content,
.stack,
.form-grid {
    display: grid;
    gap: 14px;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sheet-actions {
    grid-template-columns: 1fr 1fr;
}

.detail-icon {
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    border-radius: 28px;
    color: var(--primary);
    background: var(--surface-strong);
}

.detail-icon i {
    width: 36px;
    height: 36px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.detail-item {
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 250, 240, .72);
}

.detail-item span {
    display: block;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 800;
}

.detail-item strong {
    display: block;
    margin-top: 4px;
}

.shopping-row {
    justify-content: space-between;
    padding: 13px;
    border-radius: 20px;
}

.shopping-row.done {
    opacity: .58;
}

.shopping-row.done h3 {
    text-decoration: line-through;
}

.check-button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border: 0;
    border-radius: 15px;
    color: var(--primary);
    background: var(--surface-strong);
}

.check-button.active {
    color: #fffaf0;
    background: var(--primary);
}

.location-card {
    display: grid;
    gap: 12px;
    padding: 15px;
    border-radius: 24px;
}

.location-card.featured {
    color: #fffaf0;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.location-card.featured h3,
.location-card.featured .muted {
    color: inherit;
}

.fill-track {
    overflow: hidden;
    height: 10px;
    border-radius: 999px;
    background: rgba(31, 39, 31, .1);
}

.location-card.featured .fill-track {
    background: rgba(255, 250, 240, .22);
}

.fill-bar {
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
}

.category-bar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
}

.mini-track {
    overflow: hidden;
    height: 8px;
    border-radius: 999px;
    background: rgba(31, 39, 31, .09);
}

.mini-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary-2);
}

.alert-card {
    display: grid;
    gap: 10px;
    padding: 14px;
    border-radius: 22px;
}

.empty-state,
.loading-state {
    display: grid;
    place-items: center;
    gap: 12px;
    min-height: 180px;
    padding: 26px;
    color: var(--muted);
    text-align: center;
}

.loading-state i {
    width: 34px;
    height: 34px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.notice {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-weight: 800;
}

.notice.success {
    color: var(--ok);
    background: rgba(39, 103, 73, .14);
}

.notice.danger {
    color: var(--danger);
    background: var(--danger-bg);
}

.install-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.install-card {
    display: grid;
    gap: 16px;
    width: min(100%, 460px);
    padding: 24px;
    border-radius: 30px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border-radius: 22px;
    color: #fffaf0;
    background: var(--primary);
    font-weight: 950;
}

@media (min-width: 820px) {
    body {
        background:
            radial-gradient(circle at 20% 10%, rgba(198, 107, 61, .16), transparent 36rem),
            linear-gradient(135deg, var(--bg) 0%, #d4b895 100%);
    }

    .app-shell {
        width: min(100%, 1120px);
        padding-inline: 26px;
    }

    .topbar {
        margin-inline: -26px;
        padding-inline: 26px;
    }

    .screen.home-screen {
        grid-template-columns: minmax(360px, .9fr) 1.1fr;
        align-items: start;
    }

    .screen.inventory-screen,
    .screen.alerts-screen,
    .screen.locations-screen,
    .screen.shopping-screen {
        grid-template-columns: 330px 1fr;
        align-items: start;
    }

    .wide-span {
        grid-column: 1 / -1;
    }

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

    .bottom-nav {
        width: min(100%, 1120px);
    }

    .fab {
        right: max(26px, calc((100vw - 1120px) / 2 + 26px));
    }
}

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