:root {
    --bg: #f7faf8;
    --panel: rgba(255, 255, 255, 0.86);
    --panel-solid: #ffffff;
    --ink: #17231d;
    --muted: #627066;
    --line: #dce7df;
    --green: #177245;
    --green-2: #25a260;
    --amber: #b77913;
    --red: #ba2b22;
    --blue: #2563b8;
    --shadow: 0 18px 45px rgba(20, 52, 34, 0.13);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(37, 162, 96, .14), transparent 34rem),
        linear-gradient(180deg, #fbfdfb 0%, var(--bg) 42%, #edf4f0 100%);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    padding-bottom: 20px;
}
button, input, select { font: inherit; }
button, .link-button {
    min-height: 44px;
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
input, select {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,.95);
    color: var(--ink);
}
label { display: grid; gap: 7px; font-weight: 800; color: var(--ink); }
.hidden { display: none !important; }
.primary {
    color: white;
    background: linear-gradient(135deg, var(--green), var(--green-2));
    box-shadow: 0 10px 24px rgba(37, 162, 96, .24);
}
.soft {
    background: rgba(255,255,255,.72);
    color: var(--ink);
    border: 1px solid rgba(220,231,223,.92);
    backdrop-filter: blur(12px);
}
.danger { color: white; background: var(--red); }
.full { width: 100%; }
.eyebrow {
    display: inline-flex;
    width: fit-content;
    border: 1px solid #bee6cf;
    color: #0b6539;
    background: #e9f8ef;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 900;
}
.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}
.login-card, .editor-card, .month-hero, .product-card, .shopping-card, .history-card {
    background: var(--panel);
    border: 1px solid rgba(220,231,223,.9);
    border-radius: 14px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}
.login-card {
    width: min(100%, 430px);
    padding: 24px;
    display: grid;
    gap: 14px;
}
.login-card h1 { font-size: clamp(34px, 11vw, 52px); line-height: .96; margin: 8px 0 0; }
.login-card p { color: var(--muted); line-height: 1.45; margin: 0; }
.error-line { min-height: 22px; color: var(--red) !important; font-weight: 900; }
.app-shell {
    width: min(980px, calc(100% - 22px));
    margin: 0 auto;
}
.app-header {
    position: static;
    z-index: 6;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    background: rgba(247,250,248,.88);
    backdrop-filter: blur(14px);
}
.app-header h1 { margin: 7px 0 0; font-size: clamp(28px, 8vw, 44px); line-height: 1; }
.month-hero { padding: 16px; display: grid; gap: 12px; }
.month-hero p { margin: 0; color: var(--muted); font-weight: 800; }
.month-hero strong { display: block; font-size: clamp(24px, 8vw, 42px); line-height: 1.05; }
.progress-shell {
    height: 14px;
    border-radius: 999px;
    background: #dfe8e2;
    overflow: hidden;
}
.progress-shell span {
    display: block;
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--green), var(--green-2));
    transition: width .25s ease;
}
.quick-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.quick-stats span {
    background: rgba(255,255,255,.74);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    color: var(--muted);
    text-align: center;
    font-size: 13px;
}
.quick-stats b { display: block; color: var(--ink); font-size: 22px; }
.purchase-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid #a7dec0;
    border-radius: 12px;
    padding: 13px 14px;
    background: linear-gradient(135deg, rgba(23, 114, 69, .96), rgba(37, 162, 96, .92));
    color: #fff;
    box-shadow: 0 12px 28px rgba(23, 114, 69, .18);
}
.purchase-total span {
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .02em;
}
.purchase-total strong {
    font-size: clamp(24px, 8vw, 38px);
    line-height: 1;
}
.view { padding: 14px 0; }
.sticky-tools {
    position: static;
    z-index: 5;
    display: grid;
    gap: 10px;
    padding: 10px 0;
    background: rgba(247,250,248,.88);
    backdrop-filter: blur(14px);
}
.segmented {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.segmented button, .bottom-nav button {
    background: rgba(255,255,255,.78);
    color: var(--muted);
    border: 1px solid var(--line);
    font-size: 13px;
}
.segmented button.active, .bottom-nav button.active {
    background: var(--ink);
    color: white;
}
.tool-row, .form-actions, .list-tools {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.list-tools { grid-template-columns: 1fr 150px; margin: 0 0 12px; }
.quick-add-card {
    display: grid;
    gap: 10px;
    margin: 0 0 12px;
    padding: 14px;
    border: 1px solid rgba(220,231,223,.9);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}
.quick-add-card strong {
    font-size: 18px;
}
.quick-add-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 8px;
}
.card-list { display: grid; gap: 10px; }
.shopping-card, .product-card, .history-card {
    padding: 14px;
    transition: transform .18s ease, opacity .18s ease, background .18s ease;
}
.shopping-card.done { background: rgba(235, 250, 241, .9); border-color: #a8dcc0; }
.shopping-card.skipped { background: rgba(255, 246, 244, .92); border-color: #efbbb4; opacity: .88; }
.card-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}
.chip {
    display: inline-flex;
    border: 1px solid #d6e4dc;
    border-radius: 999px;
    padding: 5px 9px;
    color: var(--muted);
    background: rgba(255,255,255,.72);
    font-size: 12px;
    font-weight: 900;
}
.card-top h2 { margin: 8px 0 0; font-size: 22px; line-height: 1.15; }
.qty-line { color: var(--muted); font-weight: 800; white-space: nowrap; }
.item-controls {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 8px;
    margin-top: 12px;
    align-items: end;
}
.price-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: end;
    margin-top: 10px;
}
.price-row span {
    color: var(--muted);
    font-weight: 900;
    padding-bottom: 12px;
    white-space: nowrap;
}
.qty-stepper {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    gap: 6px;
}
.qty-stepper button { padding: 0; font-size: 22px; }
.done-btn { background: var(--green); color: white; }
.skip-btn { background: var(--amber); color: white; }
.revert-btn { background: var(--blue); color: white; }
.editor-card {
    padding: 14px;
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
}
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch-line {
    display: flex;
    align-items: center;
    gap: 10px;
}
.switch-line input { width: 20px; min-height: 20px; }
.product-card.inactive { opacity: .62; }
.product-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
}
.bottom-nav {
    position: static;
    width: min(980px, calc(100% - 22px));
    margin: 12px auto 18px;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 8px;
    border: 1px solid rgba(220,231,223,.9);
    border-radius: 16px;
    background: rgba(255,255,255,.82);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}
.toast {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 92px;
    z-index: 20;
    min-height: 44px;
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--ink);
    color: white;
    font-weight: 900;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.empty {
    padding: 24px;
    border: 1px dashed #b8c9bf;
    border-radius: 14px;
    background: rgba(255,255,255,.68);
    color: var(--muted);
    text-align: center;
    font-weight: 800;
}
@media (min-width: 760px) {
    .bottom-nav { width: min(520px, calc(100% - 22px)); }
    .card-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .shopping-card { min-height: 184px; }
}
@media (max-width: 520px) {
    .tool-row, .product-actions { grid-template-columns: 1fr; }
    .item-controls { grid-template-columns: 1fr; }
    .price-row, .quick-add-grid { grid-template-columns: 1fr; }
    .segmented { grid-template-columns: repeat(2, 1fr); }
    .two-cols, .list-tools { grid-template-columns: 1fr; }
}
