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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 16px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    padding: 24px;
    text-align: center;
}

.header h1 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 8px;
}

.header p {
    opacity: 0.9;
    font-size: 1.1rem;
}

.main-content {
    padding: 24px;
}

.store-setup {
    background: #f8f9fa;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    border: 2px solid #e9ecef;
}

.store-setup h2 {
    color: #495057;
    margin-bottom: 16px;
    font-size: 1.4rem;
}

.store-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.input-group {
    position: relative;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.btn-success {
    background: linear-gradient(135deg, #00d2ff, #3a7bd5);
}

.btn-danger {
    background: linear-gradient(135deg, #ff416c, #ff4b2b);
}

.shopping-list {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 16px 8px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
}

td {
    padding: 12px 8px;
    border-bottom: 1px solid #f1f3f4;
    vertical-align: middle;
}

td input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
    min-width: 80px;
}

td input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.item-name-input {
    min-width: 120px !important;
}

.total-cell {
    font-weight: 600;
    color: #495057;
    background: #f8f9fa;
    text-align: center;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 20px 0;
    justify-content: center;
}

.totals-section {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 24px;
    margin: 24px -24px -24px -24px;
    text-align: center;
}

.totals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.total-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.total-card h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    opacity: 0.9;
}

.total-amount {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
}

.savings-info {
    margin-top: 20px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.delete-btn {
    background: #ff4757;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.delete-btn:hover {
    background: #ff3838;
    transform: scale(1.1);
}

.status {
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    margin: 16px 0;
    font-weight: 500;
}

.status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

@media (max-width: 768px) {
    body {
        padding: 8px;
    }

    .main-content {
        padding: 16px;
    }

    .header {
        padding: 20px 16px;
    }

    table {
        font-size: 0.8rem;
    }

    th,
    td {
        padding: 8px 4px;
    }

    td input {
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    .actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        padding: 14px;
    }

    .totals-section {
        margin: 16px -16px -16px -16px;
        padding: 20px 16px;
    }
}

/* Landscape orientation improvements */
@media (max-height: 600px) and (orientation: landscape) {
    .header {
        padding: 12px 16px;
    }

    .header h1 {
        font-size: 1.8rem;
        margin-bottom: 4px;
    }

    .header p {
        font-size: 1rem;
    }

    .store-setup {
        padding: 16px;
        margin-bottom: 16px;
    }

    .store-setup h2 {
        font-size: 1.2rem;
        margin-bottom: 12px;
    }

    .main-content {
        padding: 16px;
    }

    table {
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 6px 4px;
    }

    .actions {
        flex-direction: row;
        justify-content: center;
        margin: 16px 0;
    }

    .btn {
        width: auto;
        min-width: 120px;
    }

    .totals-section {
        padding: 16px;
    }
}

.hidden {
    display: none;
}