:root {
    color-scheme: light;
    --bg: #f4f5ef;
    --surface: #ffffff;
    --ink: #1f2923;
    --muted: #6b756f;
    --primary: #276749;
    --primary-dark: #1f513a;
    --line: #dfe4dc;
    --danger-bg: #fff0ed;
    --danger: #9b2c2c;
    --success-bg: #eaf7ee;
    --success: #24613f;
    --shadow: 0 16px 45px rgba(31, 41, 35, 0.10);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
}

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

.auth-page {
    display: grid;
    place-items: center;
    padding: 24px 18px;
    background:
        radial-gradient(circle at top left, rgba(101, 163, 122, .20), transparent 38%),
        var(--bg);
}

.auth-card {
    width: min(100%, 430px);
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-card h1 { margin: 10px 0 6px; }

.brand-mark {
    display: grid;
    width: 50px;
    height: 50px;
    place-items: center;
    border-radius: 16px;
    background: var(--primary);
    color: white;
    font-size: 28px;
}

.muted { margin-top: 0; color: var(--muted); }
.stack { display: grid; gap: 16px; margin-top: 22px; }

label {
    display: grid;
    gap: 7px;
    color: #3d4942;
    font-size: .9rem;
    font-weight: 650;
}

input {
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    border: 1px solid #cbd3cc;
    border-radius: 12px;
    background: white;
    color: var(--ink);
    font-size: 1rem;
}

select, textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid #cbd3cc;
    border-radius: 12px;
    background: white;
    color: var(--ink);
    font-size: 1rem;
}

select { min-height: 48px; }
textarea { resize: vertical; }
select:focus, textarea:focus { border-color: var(--primary); outline: 3px solid rgba(39, 103, 73, .15); }

input:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(39, 103, 73, .15);
}

.button, .icon-button {
    border: 0;
    cursor: pointer;
    text-decoration: none;
}

.button {
    display: inline-flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border-radius: 12px;
    font-weight: 750;
}

.button-primary { background: var(--primary); color: white; }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { border: 1px solid var(--line); background: white; color: var(--ink); }

.notice {
    margin: 18px 0;
    padding: 12px 14px;
    border-radius: 12px;
    line-height: 1.45;
}

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

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px 14px;
}

.app-header h1 { margin: 2px 0 0; font-size: clamp(1.7rem, 7vw, 2.3rem); }
.eyebrow { color: var(--primary); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

.icon-button {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink);
    font-size: 1.3rem;
}

.app-content { max-width: 900px; margin: 0 auto; padding: 12px 20px 110px; }

.empty-state {
    margin-top: 8vh;
    padding: 34px 24px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--surface);
    text-align: center;
    box-shadow: var(--shadow);
}

.empty-state h2 { margin-bottom: 8px; }
.empty-state p { max-width: 430px; margin: 0 auto 18px; color: var(--muted); line-height: 1.55; }
.empty-state small { color: var(--muted); }
.empty-icon { font-size: 2.5rem; color: var(--primary); }

.bottom-nav {
    position: fixed;
    z-index: 10;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 8px max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(12px);
}

.bottom-nav a {
    display: grid;
    gap: 3px;
    justify-items: center;
    padding: 7px 5px;
    border-radius: 12px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
    text-decoration: none;
}

.bottom-nav a span { font-size: 1.25rem; }
.bottom-nav a.active { background: #edf5ef; color: var(--primary); }

.stock-layout { display: grid; gap: 20px; }
.panel { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.panel summary { padding: 18px 20px; cursor: pointer; color: var(--primary); font-weight: 800; list-style-position: inside; }
.panel[open] summary { border-bottom: 1px solid var(--line); }
.stock-form { display: grid; gap: 16px; padding: 20px; }
.stock-form fieldset { margin: 0; padding: 0; border: 0; }
.stock-form legend { margin-bottom: 8px; color: #3d4942; font-size: .9rem; font-weight: 650; }
.tracking-choice { display: flex; flex-wrap: wrap; gap: 10px; }
.tracking-choice label { display: flex; flex: 1 1 150px; grid-template-columns: auto 1fr; align-items: center; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: #fafbf8; }
.tracking-choice input { width: 20px; min-height: auto; accent-color: var(--primary); }
.field-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; }
.optional { color: var(--muted); font-size: .78rem; font-weight: 500; }
[hidden] { display: none !important; }
.stock-section { display: grid; gap: 14px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.section-heading > div { display: flex; align-items: center; gap: 9px; }
.section-heading h2 { margin: 0; font-size: 1.3rem; }
.count-badge { display: grid; min-width: 30px; height: 30px; place-items: center; padding: 0 8px; border-radius: 999px; background: #dfeee4; color: var(--primary); font-size: .85rem; font-weight: 800; }
.search-form { width: min(52%, 280px); }
.search-form input { min-height: 42px; }
.stock-list { display: grid; gap: 10px; }
.stock-card { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.stock-card h3 { margin: 0 0 3px; font-size: 1.03rem; }
.stock-card p { margin: 0; color: var(--muted); font-size: .86rem; }
.stock-photo { display: grid; width: 64px; height: 64px; place-items: center; overflow: hidden; border-radius: 14px; background: #e4eee6; color: var(--primary); font-size: 1.6rem; font-weight: 850; }
.stock-photo img { width: 100%; height: 100%; object-fit: cover; }
.stock-card-info { min-width: 0; }
.stock-value { padding: 7px 10px; border-radius: 999px; background: #edf5ef; color: var(--primary); white-space: nowrap; font-size: .88rem; }
.stock-value.state-low { background: #fff5d9; color: #815b08; }
.stock-value.state-empty { background: var(--danger-bg); color: var(--danger); }
.stock-card-actions { display: grid; gap: 7px; justify-items: end; }
.edit-link { padding: 4px 7px; color: var(--primary); font-size: .82rem; font-weight: 750; text-decoration: none; }
.edit-link:hover { text-decoration: underline; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.form-actions .button { flex: 1; }
.stock-notes { grid-column: 2 / -1; padding-top: 8px; border-top: 1px dashed var(--line); }
.photo-field { gap: 10px; }
.photo-field input[type="file"] { padding: 8px; }
.form-photo-preview { width: 96px; height: 96px; object-fit: cover; border-radius: 14px; border: 1px solid var(--line); }
.field-help { color: var(--muted); font-weight: 450; }
.shopping-add-form { grid-column: 2 / -1; }
.shopping-button { width: 100%; min-height: 40px; padding: 8px 12px; background: #edf5ef; color: var(--primary); font-size: .85rem; }
.shopping-layout { display: grid; gap: 16px; }
.shopping-heading { display: flex; align-items: baseline; gap: 9px; }
.shopping-heading strong { color: var(--primary); font-size: 2rem; }
.shopping-heading span { color: var(--muted); }
.shopping-list { display: grid; gap: 9px; }
.shopping-row { margin: 0; }
.check-button { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; width: 100%; align-items: center; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; }
.check-button > span:first-child { display: grid; width: 30px; height: 30px; place-items: center; border: 2px solid #aab7ae; border-radius: 9px; color: white; }
.shopping-label { font-weight: 750; }
.shopping-row.checked .check-button { opacity: .58; }
.shopping-row.checked .check-button > span:first-child { border-color: var(--primary); background: var(--primary); }
.shopping-row.checked .shopping-label { text-decoration: line-through; }
.empty-list { padding: 30px 20px; border: 1px dashed #bdc8bf; border-radius: 16px; color: var(--muted); text-align: center; }
.empty-list span { color: var(--primary); font-size: 2rem; }
.empty-list p { margin: 8px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (min-width: 720px) {
    .stock-form { grid-template-columns: 1fr 1fr; }
    .field-wide { grid-column: 1 / -1; }
    .bottom-nav {
        right: auto;
        bottom: 22px;
        left: 50%;
        width: 480px;
        transform: translateX(-50%);
        border: 1px solid var(--line);
        border-radius: 18px;
        box-shadow: var(--shadow);
    }
}
