* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f0f4f0;
    color: #1a1a1a;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 0 150px;
}

header {
    background: #2d6a4f;
    color: white;
    padding: 16px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

header .subtitle {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.85;
    margin-top: 4px;
}

/* List */
.list {
    padding: 8px 12px;
}

.category-heading {
    margin: 12px 2px 6px;
    color: #2d6a4f;
    font-size: 0.9rem;
    font-weight: 700;
}

.category-group:first-child .category-heading {
    margin-top: 4px;
}

/* Item row */
.item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border-radius: 10px;
    padding: 10px 10px;
    margin-bottom: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: opacity 0.2s;
}

.item.completed {
    opacity: 0.5;
}

.item.completed .item-name {
    text-decoration: line-through;
    color: #888;
}

.item-name {
    flex: 1;
    font-size: 1rem;
    min-width: 0;
    word-break: break-word;
}

.item input[type="checkbox"] {
    width: 28px;
    height: 28px;
    accent-color: #2d6a4f;
    cursor: pointer;
    flex-shrink: 0;
}

.item .price-input {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    text-align: right;
    flex-shrink: 0;
    background: #f8faf8;
    color: #333;
    font-variant-numeric: tabular-nums;
}

.item .price-input:focus {
    outline: none;
    border-color: #2d6a4f;
    background: white;
}

.item .price-display {
    width: 80px;
    text-align: right;
    font-size: 0.95rem;
    color: #555;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    padding: 0 4px;
}

.item .delete-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
    min-width: 40px;
    min-height: 40px;
    opacity: 0.55;
    transition: opacity 0.2s;
    flex-shrink: 0;
    line-height: 1;
}

.item .delete-btn:hover,
.item .delete-btn:active {
    opacity: 1;
}

/* Total bar */
.total-bar {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1b4332;
    color: white;
    padding: 14px 20px;
    font-size: 1.2rem;
    font-weight: 700;
    z-index: 20;
    letter-spacing: 0.5px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
}

.total-label {
    opacity: 0.9;
}

.total-amount {
    font-variant-numeric: tabular-nums;
}

/* Action buttons */
.actions {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: white;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    z-index: 20;
}

.btn {
    flex: 1;
    padding: 14px 8px;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: background 0.2s;
}

.btn-add {
    background: #2d6a4f;
    color: white;
}

.btn-add:active {
    background: #245840;
}

.btn-clear {
    background: #e8e8e8;
    color: #555;
}

.btn-clear:active {
    background: #ddd;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 480px;
    padding: 24px 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 100dvh;
    overflow-y: auto;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.modal-content h2 {
    font-size: 1.2rem;
    color: #1a1a1a;
}

.modal-content input,
.modal-content select {
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    width: 100%;
    background: white;
}

.modal-content input:focus,
.modal-content select:focus {
    outline: none;
    border-color: #2d6a4f;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.btn-cancel {
    background: #e8e8e8;
    color: #555;
}

.btn-cancel:active {
    background: #ddd;
}

.btn-add-confirm {
    background: #2d6a4f;
    color: white;
}

.btn-add-confirm:active {
    background: #245840;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #66706a;
    font-size: 1rem;
}

.app-footer {
    margin: 18px 20px 0;
    color: #66706a;
    font-size: 0.75rem;
    line-height: 1.45;
    text-align: center;
}

.install-area {
    margin-bottom: 12px;
}

.install-btn {
    padding: 8px 12px;
    border: 1px solid #9eaca3;
    border-radius: 7px;
    background: transparent;
    color: #2d6a4f;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.install-instructions {
    max-width: 280px;
    margin: 8px auto 0;
    padding: 10px 14px;
    border: 1px solid #d3dbd5;
    border-radius: 8px;
    background: #f8faf8;
    color: #45534b;
    text-align: left;
}

.install-instructions ol {
    margin: 5px 0 0 20px;
}

.free-message {
    color: #45534b;
    font-weight: 600;
}

.support-note {
    margin-top: 12px;
}

.coffee-link {
    display: inline-block;
    margin-top: 7px;
    padding: 8px 10px;
    border: 1px solid #b8c3bc;
    border-radius: 7px;
    color: #2d6a4f;
    font-size: 0.72rem;
    font-weight: 700;
    text-decoration: none;
}

.attribution {
    margin-top: 12px;
    opacity: 0.8;
}

.attribution a {
    color: inherit;
}

.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible {
    outline: 3px solid #f4a261;
    outline-offset: 2px;
}

@media (max-width: 360px) {
    .item {
        gap: 6px;
        padding-left: 8px;
        padding-right: 6px;
    }

    .item .price-input {
        width: 74px;
    }

    .btn {
        font-size: 0.8rem;
    }
}
